#include <stdio.h>
int m, n, h;
int map[105][105][105], cnt[105][105][105];
int q[1000050][3], f, r, chk;
int x, y, z, dab;
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 main()
{
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
int i, j, l, k;
scanf("%d%d%d", &m, &n, &h);
for (i=0;i<=h+1;i++) {
for (j=0;j<=n+1;j++) {
for (l=0;l<=m+1;l++) {
map[i][j][l] = -1;
cnt[i][j][l] = 0;
}
}
}
f=r=0;
for (i=1;i<=h;i++) {
for (j=1;j<=n;j++) {
for (l=1;l<=m;l++) {
scanf("%d", &map[i][j][l]);
if (map[i][j][l] == 1)
{
q[r][0]=i;
q[r][1]=j;
q[r][2]=l;
r++;
}
}
}
}
while (f<r) {
x = q[f][0];
y = q[f][1];
z = q[f][2];
f++;
for (k=0;k<6;k++) {
if (map[x+dx[k]][y+dy[k]][z+dz[k]] == 0)
{
map[x+dx[k]][y+dy[k]][z+dz[k]] = 1;
cnt[x+dx[k]][y+dy[k]][z+dz[k]] =
cnt[x][y][z] + 1;
q[r][0]=x+dx[k];
q[r][1]=y+dy[k];
q[r][2]=z+dz[k];
r++;
}
}
}
dab=0;
chk = -1;
for (i=1;i<=h;i++) {
for (j=1;j<=n;j++) {
for (l=1;l<=m;l++) {
if (dab < cnt[i][j][l])
dab = cnt[i][j][l];
if (map[i][j][l] == 0) chk = 1;
}
}
}
if (chk == 1)
printf("-1\n");
else printf("%d\n", dab);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
21540 KB |
close (syscall #3) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
21540 KB |
close (syscall #3) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
21540 KB |
close (syscall #3) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
21540 KB |
close (syscall #3) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
21540 KB |
close (syscall #3) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
21540 KB |
close (syscall #3) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
21540 KB |
close (syscall #3) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
21540 KB |
close (syscall #3) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
21540 KB |
close (syscall #3) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
21540 KB |
close (syscall #3) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |