답안 #3329

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
3329 2013-08-30T12:00:17 Z mjy0503 일도양단! (kriii1_1) C++
0 / 1
100 ms 1548 KB
#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 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)));
	if(ans==-1)while(1);
	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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1548 KB Output is correct
2 Correct 0 ms 1548 KB Output is correct
3 Correct 0 ms 1548 KB Output is correct
4 Correct 0 ms 1548 KB Output is correct
5 Correct 0 ms 1548 KB Output is correct
6 Correct 0 ms 1548 KB Output is correct
7 Correct 0 ms 1548 KB Output is correct
8 Execution timed out 100 ms 1544 KB Program timed out
9 Halted 0 ms 0 KB -