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<stdio.h>
int d[10000][10000];
int z[10000][10000];
int main()
{
int g,s,c,i,j,cc=1,ff,fff;
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
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 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... |