# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3327 | mjy0503 | 일도양단! (kriii1_1) | C++98 | 0 ms | 1548 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#define min(a,b) ((a<b)?a:b)
#define max(a,b) ((a>b)?a:b)
int n,m,h,kk;
bool map[7][7][7];
int tbl[7][7][7][7][7][7];
int back(int r1,int r2,int c1,int c2,int h1,int h2){
int i,j,k,cnt=0;
if(tbl[r1][r2][c1][c2][h1][h2]!=0)
return tbl[r1][r2][c1][c2][h1][h2];
for(i=r1;i<r2;i++){
for(j=c1;j<c2;j++){
for(k=h1;k<h2;k++){
if(map[i][j][k])
cnt++;
}
}
}
if(cnt==1){
tbl[r1][r2][c1][c2][h1][h2]=(r2-r1)*(c2-c1)*(h2-h1);
return (r2-r1)*(c2-c1)*(h2-h1);
}
if(cnt==0){
tbl[r1][r2][c1][c2][h1][h2]=-1;
return -1;
}
int max=-1;
for(i=r1+1;i<r2;i++){
if(max<min(back(r1,i,c1,c2,h1,h2),back(i,r2,c1,c2,h1,h2)))
max=min(back(r1,i,c1,c2,h1,h2),back(i,r2,c1,c2,h1,h2));
}
for(i=c1+1;i<c2;i++){
if(max<min(back(r1,r2,c1,i,h1,h2),back(r1,r2,i,c2,h1,h2)))
max=min(back(r1,r2,c1,i,h1,h2),back(r1,r2,i,c2,h1,h2));
}
for(i=h1+1;i<h2;i++){
if(max<min(back(r1,r2,c1,c2,h1,i),back(r1,r2,c1,c2,i,h2)))
max=min(back(r1,r2,c1,c2,h1,i),back(r1,r2,c1,c2,i,h2));
}
tbl[r1][r2][c1][c2][h1][h2]=max;
return max;
}
int main(){
int i,a,b,c;
scanf("%d %d %d %d",&n,&m,&h,&kk);
for(i=0;i<kk;i++){
scanf("%d %d %d",&a,&b,&c);
a--;b--;c--;
map[a][b][c]=1;
}
printf("%d\n",back(0,n,0,m,0,h));
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |