Submission #00143
ソースコード
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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | #include<iostream> using namespace std; int dfs( int x, int y); int dx[4]={0,1,0,-1}; int dy[4]={1,0,-1,0}; char s[100]={ 'a' , 'b' , 'c' , 'd' , 'e' , 'f' , 'g' , 'h' , 'i' , 'j' , 'k' , 'l' , 'm' , 'n' , 'o' , 'p' , 'q' , 'r' , 's' , 't' , 'u' , 'v' , 'w' , 'x' , 'y' , 'z' , 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' , 'H' , 'I' , 'J' , 'K' , 'L' , 'M' , 'N' , 'O' , 'P' , 'Q' , 'R' , 'S' , 'T' , 'U' , 'V' , 'W' , 'X' , 'Y' , 'Z' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , '!' , '"' , '$' , '%' , '&' , '(' , ')' , '=' , '~' , '?' , '@' , '{' , '}' , '*' , '+' , ';' , '[' , ']' , ':' , '/' }; int h,w,k=0; char maps[1010][1010]; int main(){ int n,sx,sy,gx,gy; int ans[10001]; cin>>h>>w; for ( int i=0;i<h;i++){ for ( int j=0;j<w;j++){ cin>>maps[i][j]; } } for ( int i=0;i<h;i++){ for ( int j=0;j<w;j++){ if (maps[i][j]== '1' ){ for ( int z=i-1;z<i+2;z++){ for ( int c=j-1;c<j+2;c++){ if (0<=z&&z<h&&0<=c&&c<w&&(maps[z][c]== '#' ||maps[z][c]== '1' )){ maps[z][c]= '.' ; } } } } if (maps[i][j]== '2' ){ for ( int z=i-2;z<i+3;z++){ for ( int c=j-2;c<j+3;c++){ if (0<=z&&z<h&&0<=c&&c<w&&(maps[z][c]== '#' ||maps[z][c]== '2' )){ maps[z][c]= '.' ; } } } } if (maps[i][j]== '3' ){ for ( int z=i-3;z<i+4;z++){ for ( int c=j-3;c<j+4;c++){ if (0<=z&&z<h&&0<=c&&c<w&&(maps[z][c]== '#' ||maps[z][c]== '3' )){ maps[z][c]= '.' ; } } } } if (maps[i][j]== '4' ){ for ( int z=i-4;z<i+5;z++){ for ( int c=j-4;c<j+5;c++){ if (0<=z&&z<h&&0<=c&&c<w&&(maps[z][c]== '#' ||maps[z][c]== '4' )){ maps[z][c]= '.' ; } } } } if (maps[i][j]== '5' ){ for ( int z=i-5;z<i+6;z++){ for ( int c=j-5;c<j+6;c++){ if (0<=z&&z<h&&0<=c&&c<w&&(maps[z][c]== '#' ||maps[z][c]== '5' )){ maps[z][c]= '.' ; } } } } if (maps[i][j]== '6' ){ for ( int z=i-6;z<i+7;z++){ for ( int c=j-6;c<j+7;c++){ if (0<=z&&z<h&&0<=c&&c<w&&(maps[z][c]== '#' ||maps[z][c]== '6' )){ maps[z][c]= '.' ; } } } } if (maps[i][j]== '7' ){ for ( int z=i-7;z<i+8;z++){ for ( int c=j-7;c<j+8;c++){ if (0<=z&&z<h&&0<=c&&c<w&&(maps[z][c]== '#' ||maps[z][c]== '7' )){ maps[z][c]= '.' ; } } } } if (maps[i][j]== '8' ){ for ( int z=i-8;z<i+9;z++){ for ( int c=j-8;c<j+9;c++){ if (0<=z&&z<h&&0<=c&&c<w&&(maps[z][c]== '#' ||maps[z][c]== '8' )){ maps[z][c]= '.' ; } } } } if (maps[i][j]== '9' ){ for ( int z=i-9;z<i+10;z++){ for ( int c=j-9;c<j+10;c++){ if (0<=z&&z<h&&0<=c&&c<w&&(maps[z][c]== '#' ||maps[z][c]== '9' )){ maps[z][c]= '.' ; } } } } } } cin>>n; for ( int i=0;i<n;i++){ cin>>sx>>sy>>gx>>gy; if (maps[sy][sx]== '.' ){ dfs(sx,sy); k++; } if (maps[sy][sx]!= '#' &&maps[gy][gx]!= '#' &&maps[sy][sx]==maps[gy][gx])ans[i]=1; } for ( int i=0;i<n;i++){ if (ans[i]==1)cout<< "yes" <<endl; else cout<< "no" <<endl; } return (0); } int dfs( int x, int y){ int rec=0; maps[y][x]=s[k]; for ( int i=0;i<4;i++){ int nx=x+dx[i]; int ny=y+dy[i]; if (nx>=0&&nx<w&&ny>=0&&ny<h&&maps[ny][nx]== '.' ){ rec+=dfs(nx,ny); } } return rec; } |
ステータス
項目 | データ |
---|---|
問題 | 0004 - 韓流ハゲ |
ユーザー名 | neko |
投稿日時 | 2017-08-08 11:35:08 |
言語 | C++11 |
状態 | Wrong Answer |
得点 | 0 |
ソースコード長 | 3120 Byte |
最大実行時間 | 87 ms |
最大メモリ使用量 | 22244 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 0 / 60 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in00.dat | AC | 12 ms | 480 KB |
1
|
in01.dat | AC | 17 ms | 544 KB |
1
|
in02.dat | AC | 15 ms | 544 KB |
1
|
in03.dat | WA | 19 ms | 1368 KB |
1
|
in04.dat | AC | 18 ms | 1192 KB |
1
|
in05.dat | AC | 17 ms | 1300 KB |
1
|
in06.dat | WA | 23 ms | 1756 KB |
1
|
in07.dat | AC | 53 ms | 2188 KB |
1
|
in08.dat | WA | 55 ms | 2468 KB |
1
|
in09.dat | WA | 70 ms | 20748 KB |
1
|
in10.dat | WA | 68 ms | 17944 KB |
1
|
in11.dat | WA | 68 ms | 19636 KB |
1
|
in12.dat | WA | 69 ms | 13968 KB |
1
|
in13.dat | WA | 78 ms | 20900 KB |
1
|
in14.dat | WA | 73 ms | 22220 KB |
1
|
in15.dat | WA | 87 ms | 22244 KB |
1
|