Submission #1780420
Source Code Expand
#include <iostream> #include <queue> using namespace std; int h,w; int ans; int il[105][105]; int kx[6]={1,1,1,0,-1,0},gx[6]={0,1,0,-1,-1,-1},ry[6]={-1,0,1,1,0,-1}; int vis[105][105]; int main(void){ cin>>w>>h; for(int i=1;i<=h;i++){ for(int j=1;j<=w;j++){ cin>>il[j][i]; } } queue<pair<int,int>>bfs; bfs.push(make_pair(0,0)); vis[0][0]=1; while(!bfs.empty()){ int s=bfs.front().first,t=bfs.front().second; bfs.pop(); for(int i=0;i<6;i++){ int x=s,y=ry[i]+t; if(t%2)x+=kx[i]; else x+=gx[i]; if(x>=0&&x<=w+1&&y>=0&&y<=h+1&&!vis[x][y]){ if(il[x][y])ans++; else{ vis[x][y]=1; bfs.push(make_pair(x,y)); } } } } cout<<ans<<endl; }
Submission Info
Submission Time | |
---|---|
Task | E - イルミネーション (Illumination) |
User | nxteru |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 918 Byte |
Status | AC |
Exec Time | 3 ms |
Memory | 384 KB |
Judge Result
Set Name | set01 | set02 | set03 | set04 | set05 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 20 / 20 | 20 / 20 | 20 / 20 | 20 / 20 | 20 / 20 | ||||||||||
Status |
|
|
|
|
|
Set Name | Test Cases |
---|---|
set01 | data1 |
set02 | data2 |
set03 | data3 |
set04 | data4 |
set05 | data5 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
data1 | AC | 1 ms | 256 KB |
data2 | AC | 2 ms | 256 KB |
data3 | AC | 3 ms | 384 KB |
data4 | AC | 3 ms | 384 KB |
data5 | AC | 3 ms | 384 KB |