#include <stdio.h>
int U[1000000],V[100][100][100],D[100][100][100];
int M,N,H,A;
int dx[6] = {1,-1,0,0,0,0};
int dy[6] = {0,0,1,-1,0,0};
int dz[6] = {0,0,0,0,1,-1};
int trans(int x, int y, int z){return z * M * N + y + x * N;}
int main()
{
int i,j,k,x,y,z,px,py,pz;
int head = -1, tail = -1;
scanf ("%d %d %d",&M,&N,&H);
for (k=0;k<H;k++) for (i=0;i<M;i++) for (j=0;j<N;j++){
scanf ("%d",&V[i][j][k]);
if (V[i][j][k] == 1) U[++head] = trans(i,j,k);
}
while (tail < head){
++tail; y = U[tail] % N; x = (U[tail] / N) % M; z = U[tail] / (N * M);
if (A < D[x][y][z])
A = D[x][y][z];
for (i=0;i<6;i++){
px = x + dx[i]; py = y + dy[i]; pz = z + dz[i];
if (px < 0 || px >= M || py < 0 || py >= N || pz < 0 || pz >= H) continue;
if (V[px][py][pz] == 0){
V[px][py][pz] = 1;
D[px][py][pz] = D[x][y][z] + 1;
U[++head] = trans(px,py,pz);
}
}
}
for (i=0;i<M;i++) for (j=0;j<N;j++) for (k=0;k<H;k++) if (V[i][j][k] == 0) A = -1;
printf ("%d",A);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
12604 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 |
Incorrect |
0 ms |
12604 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 |
Correct |
0 ms |
12604 KB |
Output is correct |
2 |
Correct |
0 ms |
12604 KB |
Output is correct |
3 |
Correct |
2 ms |
12604 KB |
Output is correct |
4 |
Correct |
0 ms |
12604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
12604 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 |
Incorrect |
10 ms |
12604 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 |
Correct |
42 ms |
12604 KB |
Output is correct |
2 |
Correct |
28 ms |
12604 KB |
Output is correct |
3 |
Correct |
45 ms |
12604 KB |
Output is correct |
4 |
Correct |
12 ms |
12604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
105 ms |
12604 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 |
Incorrect |
102 ms |
12604 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 |
Correct |
183 ms |
12604 KB |
Output is correct |
2 |
Correct |
161 ms |
12604 KB |
Output is correct |
3 |
Correct |
169 ms |
12604 KB |
Output is correct |
4 |
Correct |
125 ms |
12604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
201 ms |
12604 KB |
Output is correct |
2 |
Incorrect |
66 ms |
12604 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |