# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
22564 | 2017-04-30T05:34:08 Z | 예제는 나오는데 왜 틀리죠??(#895, baactree) | Young Zebra (KRIII5_YZ) | C++14 | 39 ms | 18756 KB |
// ===================================================================================== // // Filename: yz.cpp // Created: 2017년 04월 30일 13시 55분 22초 // Compiler: g++ -O2 -std=c++14 // Author: baactree , [email protected] // Company: Chonnam National University // // ===================================================================================== #include <bits/stdc++.h> using namespace std; int n, m; char mat[1300][1300]; int check[1205][1205]; int _count[1205*1205]; int trip[3][3]; int dx[4]={-1, 1, 0, 0}; int dy[4]={0, 0, -1, 1}; bool safe(int x, int y){ return x>=0&&x<3*n&&y>=0&&y<3*m; } int dfs(int x, int y, int idx){ check[x][y]=idx; int ret=1; for(int i=0;i<4;i++){ int nx=x+dx[i]; int ny=y+dy[i]; if(safe(nx, ny)&&!check[nx][ny]&&mat[nx][ny]==mat[x][y]) ret+=dfs(nx, ny, idx); } return ret; } int main(){ scanf("%d%d", &n, &m); for(int i=0;i<n;i++) scanf("%s", &mat[i]); for(int i=0;i<n;i++) for(int j=0;j<m;j++){ mat[i+n][j]=mat[i+n*2][j]=mat[i][j+m]=mat[i+n][j+m]=mat[i+n*2][j+m]= mat[i][j+m*2]=mat[i+n][j+m*2]=mat[i+n*2][j+m*2]=mat[i][j]; } int idx=1; for(int i=0;i<n;i++){ for(int j=0;j<m;j++) if(!check[i+n][j+m]){ int temp=dfs(i+n, j+m, idx); for(int k=0;k<3;k++) for(int q=0;q<3;q++){ if(k==1&&q==1) continue; if(check[i+k*n][j+q*m]==idx) temp=-1; } _count[idx]=temp; idx++; } } for(int i=0;i<n;i++){ for(int j=0;j<m;j++) printf("%d ", _count[check[i+n][j+m]]); printf("\n"); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Partially correct | 36 ms | 18756 KB | Output is partially correct |
2 | Incorrect | 39 ms | 18544 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |