Submission #3333

#TimeUsernameProblemLanguageResultExecution timeMemory
3333mjy0503일도양단! (kriii1_1)C++98
1 / 1
4 ms1772 KiB
#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][8][7][8][7][8]; 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 ans=-1; for(i=r1+1;i<r2;i++) ans=max(ans,min(back(r1,i,c1,c2,h1,h2),back(i,r2,c1,c2,h1,h2))); for(i=c1+1;i<c2;i++) ans=max(ans,min(back(r1,r2,c1,i,h1,h2),back(r1,r2,i,c2,h1,h2))); for(i=h1+1;i<h2;i++) ans=max(ans,min(back(r1,r2,c1,c2,h1,i),back(r1,r2,c1,c2,i,h2))); tbl[r1][r2][c1][c2][h1][h2]=ans; return ans; } 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 timeMemoryGrader output
Fetching results...