답안 #1148

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1148 2013-06-28T02:54:22 Z hgp744 토마토 (3차원) (KOI13_tomato3D) C
20 / 20
165 ms 21548 KB
#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()
{

     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 Correct 0 ms 21548 KB Output is correct
2 Correct 3 ms 21548 KB Output is correct
3 Correct 0 ms 21548 KB Output is correct
4 Correct 2 ms 21548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 21548 KB Output is correct
2 Correct 3 ms 21548 KB Output is correct
3 Correct 2 ms 21548 KB Output is correct
4 Correct 1 ms 21548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 21548 KB Output is correct
2 Correct 0 ms 21548 KB Output is correct
3 Correct 1 ms 21548 KB Output is correct
4 Correct 0 ms 21548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 21548 KB Output is correct
2 Correct 19 ms 21548 KB Output is correct
3 Correct 27 ms 21548 KB Output is correct
4 Correct 40 ms 21548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 21548 KB Output is correct
2 Correct 5 ms 21548 KB Output is correct
3 Correct 20 ms 21548 KB Output is correct
4 Correct 8 ms 21548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 21548 KB Output is correct
2 Correct 23 ms 21548 KB Output is correct
3 Correct 31 ms 21548 KB Output is correct
4 Correct 11 ms 21548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 85 ms 21548 KB Output is correct
2 Correct 43 ms 21548 KB Output is correct
3 Correct 94 ms 21548 KB Output is correct
4 Correct 14 ms 21548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 86 ms 21548 KB Output is correct
2 Correct 104 ms 21548 KB Output is correct
3 Correct 85 ms 21548 KB Output is correct
4 Correct 114 ms 21548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 157 ms 21548 KB Output is correct
2 Correct 127 ms 21548 KB Output is correct
3 Correct 129 ms 21548 KB Output is correct
4 Correct 127 ms 21548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 165 ms 21548 KB Output is correct
2 Correct 57 ms 21548 KB Output is correct
3 Correct 164 ms 21548 KB Output is correct
4 Correct 52 ms 21548 KB Output is correct