Submission #19535

# Submission time Handle Problem Language Result Execution time Memory
19535 2016-02-24T16:47:02 Z gs14004 일도양단! (kriii1_1) C++14
0 / 1
0 ms 1724 KB
#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; 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, sz, 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, sz, 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
1 Incorrect 0 ms 1724 KB Output isn't correct
2 Halted 0 ms 0 KB -