# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
22580 | 2017-04-30T05:42:32 Z | dried chocochip on Daegu asphalt(#897, suzy, zych1751, Acka) | Young Zebra (KRIII5_YZ) | C++11 | 243 ms | 52712 KB |
#include<bits/stdc++.h> using namespace std; int n, m; char mmap[2000][2000]; int cc[2000][2000], c_idx; bool visited[2000][2000]; int cc_sz[2000*2000+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 >= 5*n || nj < 0 || nj >= 5*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 < 5*n; i++) for(int j = 0; j < 5*m; j++) mmap[i][j] = mmap[i%n][j%m]; for(int i = 0; i < 5*n; i++) for(int j = 0; j < 5*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 < 5; ddi++) for(int ddj = 0; ddj < 5; ddj++) { if(ddi == 2 && ddj == 2) continue; if(cc[i+n*2][j+m*2] == cc[i+ddi*n][j+ddj*m]) check = true; } printf("%d ", cc_sz[cc[i+n*2][j+m*2]]); } printf("\n"); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Partially correct | 243 ms | 51120 KB | Output is partially correct |
2 | Incorrect | 209 ms | 52712 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |