Submission #1118

#TimeUsernameProblemLanguageResultExecution timeMemory
1118jiws829토마토 (KOI13_tomato)C++98
0 / 16
1000 ms5000 KiB
#include<stdio.h> int n,m; int p[1001][1001]; int check() { int i,j; int r=0,a=0; for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { if(p[i][j]==1) r=1; if(p[i][j]==0) a=1; } } if(a==1 && r==1) return 0; if(a==0 && r==1) return 1; if(r==0) return -1; } void make() { int i,j; for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { if(p[i][j]==1) { p[i-1][j]=p[i+1][j]=p[i][j-1]=p[i][j+1]=2; } } } } int main() { scanf("%d %d",&m,&n); int i,j,k,r; for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { scanf("%d",&p[i][j]); } } for(k=0;;k++) { r=check(); if(r) break; make(); for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { if(p[i][j]==2) { p[i][j]=1; } } } if(r==1) break; } if(r==-1) printf("-1"); else printf("%d\n",k); }
#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...