Submission #3346

#TimeUsernameProblemLanguageResultExecution timeMemory
3346movie_jo일도양단! (kriii1_1)C11
1 / 1
4 ms1548 KiB
#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; for(i = 1; i < R; i++) { y = f(a + i, b, c, R - i, C, H); if(y == -1) 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 == -1) 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 == -1) 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 timeMemoryGrader output
Fetching results...