# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
22508 | 2017-04-30T05:10:40 Z | dried chocochip on Daegu asphalt(#897, suzy, zych1751, Acka) | Young Zebra (KRIII5_YZ) | C++11 | 93 ms | 21888 KB |
#include<bits/stdc++.h> using namespace std; int n, m; char mmap[1200][1200]; int cc[1200][1200], c_idx; bool visited[1200][1200]; int cc_sz[1200*1200+2]; int di[4] = {-1, 0, 1, 0}; int dj[4] = {0, 1, 0, -1}; void dfs(int i, int j) { visited[i][j] = true; cc[i][j] = c_idx; cc_sz[c_idx]++; for(int k = 0; k < 4; k++) { int ni = i+di[k], nj = j+dj[k]; if(ni < 0 || ni >= 3*n || nj < 0 || nj >= 3*m) continue; if(!visited[ni][nj] && mmap[i][j] == mmap[ni][nj]) dfs(ni, nj); } } int main() { scanf("%d %d", &n, &m); for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) scanf(" %c", &mmap[i][j]); for(int i = 0; i < 3*n; i++) for(int j = 0; j < 3*m; j++) mmap[i][j] = mmap[i%n][j%m]; for(int i = 0; i < 3*n; i++) for(int j = 0; j < 3*m; j++) if(!visited[i][j]) { c_idx++; dfs(i, j); } for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { bool check = false; for(int ddi = 0; ddi < 3; ddi++) for(int ddj = 0; ddj < 3; ddj++) { if(ddi == 1 && ddj == 1) continue; if(cc[i+n][j+m] == cc[i+ddi*n][j+ddj*m]) check = true; } printf("%d ", cc_sz[cc[i+n][j+m]]); } printf("\n"); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Partially correct | 93 ms | 21888 KB | Output is partially correct |
2 | Incorrect | 79 ms | 21220 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |