# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
5163 | cki86201 | 일도양단! (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>
#include<algorithm>
using namespace std;
int d[8][8][8][8][8][8];
int p[8][8][8];
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define get(x1,x2,y1,y2,z1,z2) (p[x2][y2][z2]-p[x2][y2][z1-1]-p[x2][y1-1][z2]-p[x1-1][y2][z2]+p[x2][y1-1][z1-1]+p[x1-1][y2][z1-1]+p[x1-1][y1-1][z2]-p[x1-1][y1-1][z1-1])
int main()
{
int R, C, H, q;
scanf("%d%d%d%d",&R,&C,&H,&q);
while(q--){
int x, y, z;
scanf("%d%d%d",&x,&y,&z);
p[x][y][z] = 1;
}
rep(i,1,R)rep(j,1,C)rep(k,1,H){
p[i][j][k] += p[i][j][k-1] + p[i][j-1][k] + p[i-1][j][k] - p[i-1][j-1][k] - p[i-1][j][k-1] - p[i][j-1][k-1] + p[i-1][j-1][k-1];
}
rep(i,0,R-1)rep(j,1,R-i)rep(k,0,C-1)rep(m,1,C-k)rep(n,0,H-1)rep(l,1,H-n){
int tmp = get(j,j+i,m,m+k,l,l+n);
if(tmp == 1)d[j][j+i][m][m+k][l][l+n] = (i+1)*(k+1)*(n+1);
else if(tmp > 1){
int u = 0;
rep(t,j,j+i-1){
int a = d[j][t][m][m+k][l][l+n];
int b = d[t+1][j+i][m][m+k][l][l+n];
if(!a || !b)continue;
u = max(u, min(a,b));
}
rep(t,m,m+k-1){
int a = d[j][j+i][m][t][l][l+n];
int b = d[j][j+i][t+1][m+k][l][l+n];
if(!a || !b)continue;
u = max(u, min(a,b));
}
rep(t,l,l+n-1){
int a = d[j][j+i][m][m+k][l][t];
int b = d[j][j+i][m][m+k][t+1][l+n];
if(!a || !b)continue;
u = max(u, min(a,b));
}
if(u)d[j][j+i][m][m+k][l][l+n] = u;
}
}
printf("%d",d[1][R][1][C][1][H]);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |