Submission #1150

#TimeUsernameProblemLanguageResultExecution timeMemory
1150hgp744토마토 (3차원) (KOI13_tomato3D)C11
2 / 20
11 ms8600 KiB
#include<stdio.h> int d[1000][1000]; int z[1000][1000]; int main() { int g,s,c,i,j,cc=1,ff,fff; scanf("%d %d %d",&g,&s,&c); for(i=1; i<=s*c; i++){ for(j=1; j<=g; j++){ scanf("%d",&d[i][j]); } } while(1){ for(i=1; i<=s*c; i++){ for(j=1; j<=g; j++){ if(d[i][j]==cc){ if(i-s>0 && d[i-s][j]==0) d[i-s][j]=cc+1; if(d[i+s][j]==0) d[i+s][j]=cc+1; if(d[i][j+1]==0) d[i][j+1]=cc+1; if(d[i][j-1]==0) d[i][j-1]=cc+1; if(d[i+1][j]==0) d[i+1][j]=cc+1; if(d[i-1][j]==0) d[i-1][j]=cc+1; } } } cc++; ff=0; fff=1; for(i=1; i<=s*c; i++){ for(j=1; j<=g; j++){ if(d[i][j]==0) ff=1; if(z[i][j]==d[i][j] && fff==1) fff=1; else fff=0; z[i][j]=d[i][j]; } } if(fff==1){ printf("-1"); return 0; } if(ff==0) break; } printf("%d",cc-1); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...