답안 #18586

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
18586 2016-02-10T07:27:48 Z eaststar 일도양단! (kriii1_1) C++14
0 / 1
9 ms 16384 KB
#include <stdio.h>
#include <algorithm>
using namespace std;
int a[8][8][8],b[8][8][8][8][8][8];
int sum(int i,int j,int k,int x,int y,int z){return a[i][j][k]-a[x][j][k]-a[i][y][k]-a[i][j][z]+a[x][y][k]+a[i][y][z]+a[x][j][z]-a[x][y][z];}
int f(int sr,int er,int sc,int ec,int sh,int eh){
    int i,s,t,&mx=b[sr][er][sc][ec][sh][eh];
    if(mx)return mx;
    s=sum(er,ec,eh,sr-1,sc-1,sh-1);
    if(!s)return 0;
    if(s==1)return (er-sr+1)*(ec-sc+1)*(eh-sh+1);
    for(i=sr;i<er;++i){
        t=min(f(sr,i,sc,ec,sh,eh),f(i+1,er,sc,ec,sh,eh));
        if(mx<t)mx=t;
    }
    for(i=sc;i<ec;++i){
        t=min(f(sr,er,sc,i,sh,eh),f(sr,er,i+1,ec,sh,eh));
        if(mx<t)mx=t;
    }
    for(i=sh;i<eh;++i){
        t=min(f(sr,er,sc,ec,sh,i),f(sr,er,sc,ec,sh,i+1));
        if(mx<t)mx=t;
    }
    return mx;
}
int main(){
    int i,j,k,r,c,h,n,x,y,z;
    scanf("%d%d%d%d",&r,&c,&h,&n);
    for(i=1;i<=n;++i)scanf("%d%d%d",&x,&y,&z),a[x][y][z]=1;
    for(i=1;i<=r;++i){
        for(j=1;j<=c;++j){
            for(k=1;k<=h;++k)a[i][j][k]-=sum(i,j,k,i-1,j-1,k-1)-a[i][j][k];
        }
    }
    printf("%d",f(1,r,1,c,1,h));
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Memory limit exceeded 9 ms 16384 KB Memory limit exceeded
2 Halted 0 ms 0 KB -