Submission #2178

#TimeUsernameProblemLanguageResultExecution timeMemory
2178gs13057토마토 (KOI13_tomato)C++98
8 / 16
1000 ms9056 KiB
#include<cstdio> int n,m,r; int d; int t[1010][1010],tmp[1010][1010]; int main(void){ int i,j,k; int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1}; scanf("%d%d",&n,&m); r=n*m; for(i=0;i<=n+1;i++) t[0][i]=t[m+1][i]=-1; for(j=0;j<=m+1;j++) t[j][0]=t[j][n+1]=-1; for(i=1;i<=m;i++) for(j=1;j<=n;j++){ scanf("%d",&t[i][j]); if(t[i][j]!=0) r--; } for(i=0;i<=m+1;i++) for(j=0;j<=n+1;j++) tmp[i][j]=t[i][j]; while(r>0){ d++; for(i=1;i<=m;i++) for(j=1;j<=n;j++) if(t[i][j]==1) for(k=0;k<4;k++) if(tmp[i+dx[k]][j+dy[k]]==0) tmp[i+dx[k]][j+dy[k]]=1,r--; for(i=1;i<=m;i++) for(j=1;j<=n;j++) t[i][j]=tmp[i][j]; } printf("%d",d); 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...