This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |