답안 #14237

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
14237 2015-05-07T11:52:51 Z moonrabbit2 토마토 (3차원) (KOI13_tomato3D) C++
컴파일 오류
0 ms 0 KB
#define MAX 100
int queue[3][MAX*MAX*MAX],check[MAX][MAX][MAX],a[MAX][MAX][MAX],top,place,m,n,h,count=1,nmax;
void queueinsert(int x,int y,int z,int c)
{
    queue[0][top]=x;
    queue[1][top]=y;
    queue[2][top++]=z;
    check[x][y][z]=c;
}
void put(int x,int y,int z)
{
    int c=check[x][y][z];
    if(y-1<0||check[x][y-1][z]!=0||a[x][y-1][z]==-1);
    else queueinsert(x,y-1,z,c+1);
    if(y+1>=n||check[x][y+1][z]!=0||a[x][y+1][z]==-1);
    else queueinsert(x,y+1,z,c+1);
    if(z-1<0||check[x][y][z-1]!=0||a[x][y][z-1]==-1);
    else queueinsert(x,y,z-1,c+1);
    if(z+1>=m||check[x][y][z+1]!=0||a[x][y][z+1]==-1);
    else queueinsert(x,y,z+1,c+1);
    if(x-1<0||check[x-1][y][z]!=0||a[x-1][y][z]==-1);
    else queueinsert(x-1,y,z,c+1);
    if(x+1>=h||check[x+1][y][z]!=0||a[x+1][y][z]==-1);
    else queueinsert(x+1,y,z,c+1);
}
int main()
{
    scanf("%d %d %d",&m,&n,&h);
    for(int i=0;i<h;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<m;k++){
                scanf("%d",&a[i][j][k]);
                if(a[i][j][k]==1)queueinsert(i,j,k,1);
            }
        }
    }
    while(m*n*h!=count){
        if(check[queue[0][place]][queue[1][place]][queue[2][place]]!=0&&a[queue[0][place]][queue[1][place]][queue[2][place]]!=-1){
            put(queue[0][place],queue[1][place],queue[2][place]);
            place++;
        }
        count++;
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<m;k++){
                if(check[i][j][k]==0&&a[i][j][k]==0){
                    printf("-1");
                    return 0;
                }
                if(check[i][j][k]>nmax)nmax=check[i][j][k];
            }
        }
    }
    printf("%d",nmax-1);
    return 0;
}

Compilation message

cc.cpp: In function ‘int main()’:
cc.cpp:28:30: error: ‘scanf’ was not declared in this scope
     scanf("%d %d %d",&m,&n,&h);
                              ^
cc.cpp:48:32: error: ‘printf’ was not declared in this scope
                     printf("-1");
                                ^
cc.cpp:55:23: error: ‘printf’ was not declared in this scope
     printf("%d",nmax-1);
                       ^