#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 time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
8596 KB |
SIGSEGV Segmentation fault |
2 |
Halted |
0 ms |
0 KB |
- |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
8600 KB |
Output is correct |
2 |
Runtime error |
0 ms |
8596 KB |
SIGSEGV Segmentation fault |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
8600 KB |
Output is correct |
2 |
Correct |
0 ms |
8600 KB |
Output is correct |
3 |
Correct |
1 ms |
8600 KB |
Output is correct |
4 |
Correct |
0 ms |
8600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
8 ms |
8596 KB |
SIGSEGV Segmentation fault |
2 |
Halted |
0 ms |
0 KB |
- |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
8600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
8596 KB |
SIGSEGV Segmentation fault |
2 |
Halted |
0 ms |
0 KB |
- |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
8596 KB |
SIGSEGV Segmentation fault |
2 |
Halted |
0 ms |
0 KB |
- |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
8596 KB |
SIGSEGV Segmentation fault |
2 |
Halted |
0 ms |
0 KB |
- |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
10 ms |
8596 KB |
SIGSEGV Segmentation fault |
2 |
Halted |
0 ms |
0 KB |
- |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
8596 KB |
SIGSEGV Segmentation fault |
2 |
Halted |
0 ms |
0 KB |
- |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |