Submission #00041
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | #include<iostream> #include<cstdio> using namespace std; char map[21][21]; int h,w; int co; int cohun; int sy,sx; int dy[4]={-1,0,1,0}; int dx[4]={0,-1,0,1}; int comax[2]; int cheack[21][21]; void bfs( int y, int x){ cohun+=co*2; if (comax[0]<co){ comax[0]=co; } if (cohun>comax[1]){ comax[1]=cohun; } cheack[y][x]=1; for ( int i=0;i<4;i++){ int ny=y+dy[i]; int nx=x+dx[i]; if (ny>=0 && ny<h && nx>=0 && nx<w && map[ny][nx]!= '@' && cheack[ny][nx]==0){ // cohun+=co*2; co++; bfs(ny,nx); cheack[y][x]=0; } } cohun-=co*2; co--; return ; } int main(){ h=0; w=0; while (1){ co=1; cohun=0; comax[0]=0; comax[1]=0; cin>>w>>h; if (!w && !h) break ; for ( int l=0;l<h;l++){ scanf ( "%s" ,map[l]); } for ( int i=0;i<h;i++){ for ( int j=0;j<w;j++){ cheack[i][j]=0; if ( map[i][j]== 'S' ){ sy=i; sx=j; } } } cheack[sy][sx]=1; bfs(sy,sx); cout<<comax[0]<<endl; cout<<comax[1]<<endl; } } |
ステータス
項目 | データ |
---|---|
問題 | 0001 - もりたのクッキー☆kiss |
ユーザー名 | ei1501 |
投稿日時 | 2015-09-16 17:52:14 |
言語 | C++11 |
状態 | Wrong Answer |
得点 | 0 |
ソースコード長 | 1058 Byte |
最大実行時間 | 24 ms |
最大メモリ使用量 | 564 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 0 / 100 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
DFS_in1.txt | WA | 18 ms | 476 KB |
1
|
DFS_in2.txt | WA | 23 ms | 456 KB |
1
|
DFS_in3.txt | AC | 24 ms | 564 KB |
1
|