Submission #19543

#TimeUsernameProblemLanguageResultExecution timeMemory
19543gs14004일도양단! (kriii1_1)C++14
1 / 1
1 ms2748 KiB
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <limits.h> #include <stack> #include <queue> #include <map> #include <set> #include <algorithm> #include <string> #include <functional> #include <vector> #include <numeric> #include <deque> #include <utility> #include <bitset> #include <iostream> using namespace std; typedef long long lint; typedef long double llf; typedef pair<int, int> pi; int a[8][8][8]; int dp[8][8][8][8][8][8]; int getsum(int sx, int ex, int sy, int ey, int sz, int ez){ return a[ex][ey][ez] - a[sx-1][ey][ez] - a[ex][sy-1][ez] - a[ex][ey][sz-1] + a[sx-1][sy-1][ez] + a[sx-1][ey][sz-1] + a[ex][sy-1][sz-1] - a[sx-1][sy-1][sz-1]; } int f(int sx, int ex, int sy, int ey, int sz, int ez){ int t = getsum(sx, ex, sy, ey, sz, ez); if(t == 0) return -1e9; if(t == 1) return (ex - sx + 1) * (ey - sy + 1) * (ez - sz + 1); if(dp[sx][ex][sy][ey][sz][ez]) return dp[sx][ex][sy][ey][sz][ez]; int ret = 0; for(int i=sx; i<ex; i++){ ret = max(ret, min(f(sx, i, sy, ey, sz, ez), f(i+1, ex, sy, ey, sz, ez))); } for(int i=sy; i<ey; i++){ ret = max(ret, min(f(sx, ex, sy, i, sz, ez), f(sx, ex, i+1, ey, sz, ez))); } for(int i=sz; i<ez; i++){ ret = max(ret, min(f(sx, ex, sy, ey, sz, i), f(sx, ex, sy, ey, i+1, ez))); } return dp[sx][ex][sy][ey][sz][ez] = ret; } int main(){ int x, y, z, n; cin >> x >> y >> z >> n; for(int i=0; i<n; i++){ int p, q, r; cin >> p >> q >> r; a[p][q][r]++; } for(int i=1; i<=x; i++){ for(int j=1; j<=y; j++){ for(int k=1; k<=z; k++){ a[i][j][k] += a[i-1][j][k] + a[i][j-1][k] + a[i][j][k-1] - a[i-1][j-1][k] - a[i-1][j][k-1] - a[i][j-1][k-1] + a[i-1][j-1][k-1]; } } } cout << f(1, x, 1, y, 1, z); }
#Verdict Execution timeMemoryGrader output
Fetching results...