Submission #3345

# Submission time Handle Problem Language Result Execution time Memory
3345 2013-08-30T13:19:12 Z movie_jo 일도양단! (kriii1_1) C
0 / 1
0 ms 1548 KB
#include <stdio.h>

int x[7][7][7];
int save[7][7][7][7][7][7];

int f(int a, int b, int c, int R, int C, int H)
{
	int i, j, k, S = 0, w, y, z, M = 1;

	if(save[a][b][c][R][C][H])
		return save[a][b][c][R][C][H];

	for(i = 0; i < R; i++)for(j = 0; j < C; j++)for(k = 0; k < H; k++)
		if(x[a + i][b + j][c + k])
			S++;

	if(S == 0)
		return 0;
	else if(S == 1)
		return R*C*H;
	else if(R*C*H < 2*S)
		return 1;

	for(i = 1; i < R; i++)
	{
		y = f(a + i, b, c, R - i, C, H);

		if(y < 2)
			break;

		w = f(a, b, c, i, C, H);
		
		z = w > y ? y : w;

		if(z > M)
			M = z;
	}

	for(i = 1; i < C; i++)
	{
		y = f(a, b + i, c, R, C - i, H);

		if(y < 2)
			break;

		w = f(a, b, c, R, i, H);
		
		z = w > y ? y : w;

		if(z > M)
			M = z;
	}

	for(i = 1; i < H; i++)
	{
		y = f(a, b, c + i, R, C, H - i);

		if(y < 2)
			break;

		w = f(a, b, c, R, C, i);

		z = w > y ? y : w;

		if(z > M)
			M = z;
	}

	save[a][b][c][R][C][H] = M;
	return M;
}

int main(void)
{
	int R, C, H, N, i, a, b, c;

	scanf("%d %d %d %d", &R, &C, &H, &N);

	for(i = 0; i < N; i++)
	{
		scanf("%d %d %d", &a, &b, &c);

		x[a - 1][b - 1][c - 1] = 1;
	}

	printf("%d\n", f(0, 0, 0, R, C, H));

	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1548 KB Output isn't correct
2 Halted 0 ms 0 KB -