Submission #1144

# Submission time Handle Problem Language Result Execution time Memory
1144 2013-06-28T02:43:01 Z hgp744 토마토 (3차원) (KOI13_tomato3D) C
0 / 20
0 ms 262144 KB
#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
1 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
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 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
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 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
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 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
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 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
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 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
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 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
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 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
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 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
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 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
3 Halted 0 ms 0 KB -
4 Halted 0 ms 0 KB -