# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
19537 | gs14004 | 일도양단! (kriii1_1) | C++14 | 0 ms | 1724 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 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 k){
if(getsum(sx, ex, sy, ey, sz, ez) != k) return -1e9;
if(k == 1) return (ex - sx + 1) * (ey - sy + 1) * (ez - sz + 1);
int ret = 0;
for(int j=1; j<k; j++){
for(int i=sx; i<ex; i++){
ret = max(ret,
min(f(sx, i, sy, ey, sz, ez, j),
f(i+1, ex, sy, ey, sz, sz, k-j)));
}
for(int i=sy; i<=ey; i++){
ret = max(ret,
min(f(sx, ex, sy, i, sz, ez, j),
f(sx, ex, i+1, ey, sz, ez, k-j)));
}
for(int i=sz; i<=ez; i++){
ret = max(ret,
min(f(sx, ex, sy, ey, sz, i, j),
f(sx, ex, sy, ey, i+1, ez, k-j)));
}
}
return 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<=y; 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, n);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |