# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3278 | ainta | 일도양단! (kriii1_1) | C++98 | 0 ms | 2112 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>
bool v[8][8][8];
int R,C,H,N,D[8][8][8][8][8][8];
int Max(int a,int b){return a<b?b:a;}
int Min(int a,int b){return a<b?a:b;}
void Do(int x1,int y1,int z1,int x2,int y2,int z2){
int i,j,k,s=0,X=x2-x1+1,Y=y2-y1+1,Z=z2-z1+1,M=0;
for(i=x1;i<=x2;i++)
for(j=y1;j<=y2;j++)
for(k=z1;k<=z2;k++)
if(v[i][j][k])s++;
if(s==1)D[x1][y1][z1][x2][y2][z2]=X*Y*Z;
if(s<=1)return;
for(i=x1;i<x2;i++){
if(!D[x1][y1][z1][i][y2][z2])Do(x1,y1,z1,i,y2,z2);
if(!D[i+1][y1][z1][x2][y2][z2])Do(i+1,y1,z1,x2,y2,z2);
M=Max(M,Min(D[x1][y1][z1][i][y2][z2],D[i+1][y1][z1][x2][y2][z2]));
}
for(i=y1;i<y2;i++){
if(!D[x1][y1][z1][x2][i][z2])Do(x1,y1,z1,x2,i,z2);
if(!D[x1][i+1][z1][x2][y2][z2])Do(x1,i+1,z1,x2,y2,z2);
M=Max(M,Min(D[x1][y1][z1][x2][i][z2],D[x1][i+1][z1][x2][y2][z2]));
}
for(i=z1;i<z2;i++){
if(!D[x1][y1][z1][x2][y2][i])Do(x1,y1,z1,x2,y2,i);
if(!D[x1][y1][i+1][x2][y2][z2])Do(x1,y1,i+1,x2,y2,z2);
M=Max(M,Min(D[x1][y1][z1][x2][y2][i],D[x1][y1][i+1][x2][y2][z2]));
}
D[x1][y1][z1][x2][y2][z2]=M;
return;
}
int main()
{
int i,j,k,l;
scanf("%d%d%d%d",&R,&C,&H,&N);
for(i=0;i<N;i++){
scanf("%d%d%d",&j,&k,&l);
v[j][k][l]=true;
}
Do(1,1,1,R,C,H);
printf("%d\n",D[1][1][1][R][C][H]);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |