# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
22663 | 2017-04-30T06:16:00 Z | 카시코이(#958, xdoju, ntopia, pps789) | Young Zebra (KRIII5_YZ) | C++11 | 26 ms | 4692 KB |
#include <cstdio> #include <queue> using namespace std; struct st{ int x, y, fx, fy; }; char s[410][410]; int cur[410][410]; int firstX[410][410]; int firstY[410][410]; int arr[160010]; queue<st> q; int dir[4][2] = {-1, 0, 0, -1, 0, 1, 1, 0}; int main(){ int N, M; scanf("%d%d", &N, &M); for(int i = 0; i < N; i++) scanf("%s", s[i]); int c = 0; for(int i = 0; i < N; i++){ for(int j = 0; j < M; j++){ if(cur[i][j] != 0) continue; cur[i][j] = ++c; int cnt = 1; while(!q.empty()) q.pop(); q.push({i, j, 0, 0}); while(!q.empty()){ st n = q.front(); q.pop(); // printf("%d %d %d %d\n", n.x, n.y, n.fx, n.fy); for(int d = 0; d < 4; d++){ int x = n.x + dir[d][0], y = n.y + dir[d][1]; int fx = n.fx, fy = n.fy; if(x < 0){ x += N; fx--; } if(y < 0){ y += M; fy--; } if(x >= N){ x -= N; fx++; } if(y >= M){ y -= M; fy++; } // printf("cand : %d %d %d %d\n", x, y, fx, fy); if(s[x][y] != s[n.x][n.y]) continue; if(cur[x][y] == 0){ q.push({x, y, fx, fy}); cur[x][y] = c; firstX[x][y] = fx; firstY[x][y] = fy; cnt++; } else{ if(firstX[x][y] != fx || firstY[x][y] != fy){ cnt = -1; break; } } } if(cnt == -1) break; } arr[c] = cnt; } } for(int i = 0; i < N; i++){ for(int j = 0; j < M; j++) printf("%d ", arr[cur[i][j]]); printf("\n"); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 4692 KB | Output is correct |
2 | Partially correct | 19 ms | 4692 KB | Output is partially correct |
3 | Partially correct | 23 ms | 4692 KB | Output is partially correct |
4 | Partially correct | 23 ms | 4692 KB | Output is partially correct |
5 | Partially correct | 23 ms | 4692 KB | Output is partially correct |
6 | Correct | 16 ms | 4692 KB | Output is correct |
7 | Correct | 23 ms | 4692 KB | Output is correct |
8 | Correct | 16 ms | 4692 KB | Output is correct |
9 | Correct | 26 ms | 4692 KB | Output is correct |
10 | Correct | 19 ms | 4692 KB | Output is correct |
11 | Partially correct | 23 ms | 4692 KB | Output is partially correct |
12 | Correct | 16 ms | 4692 KB | Output is correct |
13 | Correct | 16 ms | 4692 KB | Output is correct |
14 | Correct | 16 ms | 4692 KB | Output is correct |
15 | Partially correct | 19 ms | 4692 KB | Output is partially correct |
16 | Correct | 19 ms | 4692 KB | Output is correct |
17 | Partially correct | 19 ms | 4692 KB | Output is partially correct |
18 | Correct | 19 ms | 4692 KB | Output is correct |
19 | Correct | 19 ms | 4692 KB | Output is correct |
20 | Partially correct | 16 ms | 4692 KB | Output is partially correct |
21 | Correct | 16 ms | 4692 KB | Output is correct |
22 | Correct | 16 ms | 4692 KB | Output is correct |
23 | Partially correct | 26 ms | 4692 KB | Output is partially correct |
24 | Partially correct | 23 ms | 4692 KB | Output is partially correct |
25 | Partially correct | 23 ms | 4692 KB | Output is partially correct |
26 | Correct | 0 ms | 4692 KB | Output is correct |
27 | Correct | 0 ms | 4692 KB | Output is correct |
28 | Correct | 0 ms | 4692 KB | Output is correct |
29 | Correct | 0 ms | 4692 KB | Output is correct |
30 | Correct | 0 ms | 4692 KB | Output is correct |
31 | Correct | 0 ms | 4692 KB | Output is correct |
32 | Partially correct | 0 ms | 4692 KB | Output is partially correct |
33 | Partially correct | 0 ms | 4692 KB | Output is partially correct |
34 | Correct | 0 ms | 4692 KB | Output is correct |
35 | Correct | 0 ms | 4692 KB | Output is correct |
36 | Correct | 0 ms | 4692 KB | Output is correct |
37 | Partially correct | 0 ms | 4692 KB | Output is partially correct |
38 | Correct | 3 ms | 4692 KB | Output is correct |
39 | Partially correct | 0 ms | 4692 KB | Output is partially correct |
40 | Partially correct | 0 ms | 4692 KB | Output is partially correct |