# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
19160 | Namnamseo | 일도양단! (kriii1_1) | C++14 | 17 ms | 2364 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 <cstdio>
int x,y,z;
int nx[100];
int ny[100];
int nz[100];
int n;
int cube(int a,int b,int c,int d,int e,int f){
int ret=0, i;
for(i=0;i<n;++i){
if(a<=nx[i] && nx[i]<=b &&
c<=ny[i] && ny[i]<=d &&
e<=nz[i] && nz[i]<=f) ++ret;
}
return ret;
}
int dp[8][8][8][8][8][8];
bool dc[8][8][8][8][8][8];
template<typename T> inline T max(T a,T b){ return b<a?a:b; }
template<typename T> inline T min(T a,T b){ return a<b?a:b; }
int work(int a,int b,int c,int d,int e,int f){
int myn = cube(a,b,c,d,e,f);
if(myn==1) return (b-a+1)*(d-c+1)*(f-e+1);
if(dc[a][b][c][d][e][f]) return dp[a][b][c][d][e][f];
dc[a][b][c][d][e][f]=1;
int& ret=dp[a][b][c][d][e][f];
int i;
for(i=a;i<b;++i) ret=max(ret, min( work(a,i,c,d,e,f), work(i+1,b,c,d,e,f) ));
for(i=c;i<d;++i) ret=max(ret, min( work(a,b,c,i,e,f), work(a,b,i+1,d,e,f) ));
for(i=e;i<f;++i) ret=max(ret, min( work(a,b,c,d,e,i), work(a,b,c,d,i+1,f) ));
return ret;
}
int main()
{
scanf("%d%d%d",&x,&y,&z);
scanf("%d",&n);
int i;
for(i=0;i<n;++i) {
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
nx[i]=a;
ny[i]=b;
nz[i]=c;
}
printf("%d\n",work(1,x,1,y,1,z));
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |