답안 #3327

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
3327 2013-08-30T11:49:41 Z mjy0503 일도양단! (kriii1_1) C++
0 / 1
0 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 max=-1;
	for(i=r1+1;i<r2;i++){
		if(max<min(back(r1,i,c1,c2,h1,h2),back(i,r2,c1,c2,h1,h2)))
			max=min(back(r1,i,c1,c2,h1,h2),back(i,r2,c1,c2,h1,h2));
	}
	for(i=c1+1;i<c2;i++){
		if(max<min(back(r1,r2,c1,i,h1,h2),back(r1,r2,i,c2,h1,h2)))
			max=min(back(r1,r2,c1,i,h1,h2),back(r1,r2,i,c2,h1,h2));
	}
	for(i=h1+1;i<h2;i++){
		if(max<min(back(r1,r2,c1,c2,h1,i),back(r1,r2,c1,c2,i,h2)))
			max=min(back(r1,r2,c1,c2,h1,i),back(r1,r2,c1,c2,i,h2));
	}
	tbl[r1][r2][c1][c2][h1][h2]=max;
	return max;
}
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 Correct 0 ms 1548 KB Output is correct
9 Correct 0 ms 1548 KB Output is correct
10 Correct 0 ms 1548 KB Output is correct
11 Correct 0 ms 1548 KB Output is correct
12 Correct 0 ms 1548 KB Output is correct
13 Correct 0 ms 1548 KB Output is correct
14 Correct 0 ms 1548 KB Output is correct
15 Correct 0 ms 1548 KB Output is correct
16 Correct 0 ms 1548 KB Output is correct
17 Correct 0 ms 1548 KB Output is correct
18 Correct 0 ms 1548 KB Output is correct
19 Correct 0 ms 1548 KB Output is correct
20 Correct 0 ms 1548 KB Output is correct
21 Correct 0 ms 1548 KB Output is correct
22 Correct 0 ms 1548 KB Output is correct
23 Correct 0 ms 1548 KB Output is correct
24 Correct 0 ms 1548 KB Output is correct
25 Correct 0 ms 1548 KB Output is correct
26 Correct 0 ms 1548 KB Output is correct
27 Correct 0 ms 1548 KB Output is correct
28 Correct 0 ms 1548 KB Output is correct
29 Correct 0 ms 1548 KB Output is correct
30 Correct 0 ms 1548 KB Output is correct
31 Correct 0 ms 1548 KB Output is correct
32 Correct 0 ms 1548 KB Output is correct
33 Correct 0 ms 1548 KB Output is correct
34 Correct 0 ms 1548 KB Output is correct
35 Correct 0 ms 1548 KB Output is correct
36 Correct 0 ms 1548 KB Output is correct
37 Correct 0 ms 1548 KB Output is correct
38 Correct 0 ms 1548 KB Output is correct
39 Incorrect 0 ms 1548 KB Output isn't correct
40 Halted 0 ms 0 KB -