Submission #3339

# Submission time Handle Problem Language Result Execution time Memory
3339 2013-08-30T12:53:03 Z pichulia 일도양단! (kriii1_1) C++
1 / 1
4 ms 1556 KB
#include<stdio.h>
struct A{
	int i, j, k;
};
struct B{
	A p,q;
};
int n, m, h, t;
int a[9][9][9];
struct A b[99];
struct B f[99];
int c[22];
int d[9][9][9];

int recode[7][7][7][7][7][7];

int ans;

bool is_equal(B p, B q)
{
	if(p.p.i == q.p.i)
	if(p.p.j == q.p.j)
	if(p.p.k == q.p.k)
	if(p.q.i == q.q.i)
	if(p.q.j == q.q.j)
	if(p.q.k == q.q.k)
		return true;
	return false;

}
void recode_in(B p,int v)
{
	recode[p.p.i-1][p.p.j-1][p.p.k-1][p.q.i-1][p.q.j-1][p.q.k-1] = v;
}
int is_recode(B p)
{
	return recode[p.p.i-1][p.p.j-1][p.p.k-1][p.q.i-1][p.q.j-1][p.q.k-1];
}
int area(B p)
{
	int i = p.q.i - p.p.i;
	int j = p.q.j - p.p.j;
	int k = p.q.k - p.p.k;
	return (i+1)*(j+1)*(k+1);
}
bool is_inside(B p, A q)
{
	if(p.p.i <= q.i && q.i <= p.q.i)
	if(p.p.j <= q.j && q.j <= p.q.j)
	if(p.p.k <= q.k && q.k <= p.q.k)
		return true;
	return false;
}
int is_in(B p)
{
	int i, j, r=0;
	for(i=0; i<t; i++)
		if(is_inside(p, b[i]))
		{
			if(r)
				return -1;
			r++;
		}
	if(r==1)
		return 1;
	return 0;
}
void print(B p)
{
	printf("%d %d %d  %d %d %d\n",p.p.i, p.p.j, p.p.k, p.q.i, p.q.j, p.q.k);
}
int dfs(B p)
{
	int in = (is_in(p));
	int r1, r2, r;
	if(in == 1)
	{
		r = area(p);
		recode_in(p, r);
		return r;
	}
	else if(in == 0)
		return 0;
	int i, j, k;
	B s, t;
	A u, v;
	s=t=p;
	u=p.q;v=p.p;
	r = 0;
	for(i=p.p.i+1; i<=p.q.i; i++)
	{
		u.i = i-1;v.i= i;
		s.q = u; t.p = v;
		r1 = is_recode(s);
		if(r1 == 0)
			r1 = dfs(s);
		if(r1>0)
		{
			r2 = is_recode(t);
			if(r2 == 0)
				r2 = dfs(t);
			if(r2>0)
			{
				recode_in(s,r1);
				recode_in(t,r2);
				if(r1>r2)r1=r2;
				if(r < r1) r = r1;
//				print(p);
//				printf("i : %d %d\n",i,r1);
			}
		}
	}
	u=p.q;v=p.p;
	for(j=p.p.j+1; j<=p.q.j; j++)
	{
		u.j = j-1;v.j= j;
		s.q = u; t.p = v;
		r1 = is_recode(s);
		if(r1 == 0)
			r1 = dfs(s);
		if(r1>0)
		{
			r2 = is_recode(t);
			if(r2 == 0)
				r2 = dfs(t);
			if(r2>0)
			{
				recode_in(s,r1);
				recode_in(t,r2);
				if(r1>r2)r1=r2;
				if(r < r1) r = r1;
//				print(p);
//				printf("j : %d %d\n",j,r1);
			}
		}
	}
	u=p.q;v=p.p;
	for(k=p.p.k+1; k<=p.q.k; k++)
	{
		u.k = k-1;v.k= k;
		s.q = u; t.p = v;
		r1 = is_recode(s);
		if(r1 == 0)
			r1 = dfs(s);
		if(r1>0)
		{
			r2 = is_recode(t);
			if(r2 == 0)
				r2 = dfs(t);
			if(r2>0)
			{
				recode_in(s, r1);
				recode_in(t, r2);
				if(r1>r2)r1=r2;
				if(r < r1) r = r1;
//				print(p);
//				print(s);
//				print(t);
//				printf("k : %d %d\n",k,r1);
			}
		}
	}
	return r;
}
void process()
{
	B p;
	A q;
	q.i = q.j = q.k = 1;
	p.p = q;
	q.i = n;q.j = m;q.k = h;
	p.q = q;

	int r = dfs(p);
	printf("%d",r);
}
int main()
{
	int i, j, k, l;
	scanf("%d %d %d %d",&n,&m,&h, &t);
	for(l=0; l<t; l++)
	{
		scanf("%d %d %d",&i,&j,&k);
		a[i][j][k] = 1;
		b[l].i = i;
		b[l].j = j;
		b[l].k = k;
	}
	process();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1556 KB Output is correct
2 Correct 0 ms 1556 KB Output is correct
3 Correct 0 ms 1556 KB Output is correct
4 Correct 0 ms 1556 KB Output is correct
5 Correct 0 ms 1556 KB Output is correct
6 Correct 0 ms 1556 KB Output is correct
7 Correct 0 ms 1556 KB Output is correct
8 Correct 0 ms 1556 KB Output is correct
9 Correct 0 ms 1556 KB Output is correct
10 Correct 0 ms 1556 KB Output is correct
11 Correct 0 ms 1556 KB Output is correct
12 Correct 0 ms 1556 KB Output is correct
13 Correct 0 ms 1556 KB Output is correct
14 Correct 0 ms 1556 KB Output is correct
15 Correct 0 ms 1556 KB Output is correct
16 Correct 0 ms 1556 KB Output is correct
17 Correct 0 ms 1556 KB Output is correct
18 Correct 0 ms 1556 KB Output is correct
19 Correct 0 ms 1556 KB Output is correct
20 Correct 0 ms 1556 KB Output is correct
21 Correct 0 ms 1556 KB Output is correct
22 Correct 0 ms 1556 KB Output is correct
23 Correct 0 ms 1556 KB Output is correct
24 Correct 0 ms 1556 KB Output is correct
25 Correct 0 ms 1556 KB Output is correct
26 Correct 4 ms 1556 KB Output is correct
27 Correct 0 ms 1556 KB Output is correct
28 Correct 0 ms 1556 KB Output is correct
29 Correct 0 ms 1556 KB Output is correct
30 Correct 0 ms 1556 KB Output is correct
31 Correct 0 ms 1556 KB Output is correct
32 Correct 0 ms 1556 KB Output is correct
33 Correct 0 ms 1556 KB Output is correct
34 Correct 0 ms 1556 KB Output is correct
35 Correct 0 ms 1556 KB Output is correct
36 Correct 0 ms 1556 KB Output is correct
37 Correct 0 ms 1556 KB Output is correct
38 Correct 0 ms 1556 KB Output is correct
39 Correct 0 ms 1556 KB Output is correct
40 Correct 0 ms 1556 KB Output is correct
41 Correct 0 ms 1556 KB Output is correct
42 Correct 0 ms 1556 KB Output is correct
43 Correct 0 ms 1556 KB Output is correct
44 Correct 0 ms 1556 KB Output is correct
45 Correct 0 ms 1556 KB Output is correct
46 Correct 0 ms 1556 KB Output is correct
47 Correct 0 ms 1556 KB Output is correct
48 Correct 0 ms 1556 KB Output is correct
49 Correct 0 ms 1556 KB Output is correct
50 Correct 0 ms 1556 KB Output is correct
51 Correct 0 ms 1556 KB Output is correct
52 Correct 0 ms 1556 KB Output is correct
53 Correct 0 ms 1556 KB Output is correct
54 Correct 0 ms 1556 KB Output is correct
55 Correct 0 ms 1556 KB Output is correct
56 Correct 0 ms 1556 KB Output is correct
57 Correct 0 ms 1556 KB Output is correct
58 Correct 0 ms 1556 KB Output is correct
59 Correct 0 ms 1556 KB Output is correct
60 Correct 0 ms 1556 KB Output is correct
61 Correct 0 ms 1556 KB Output is correct
62 Correct 0 ms 1556 KB Output is correct
63 Correct 0 ms 1556 KB Output is correct
64 Correct 0 ms 1556 KB Output is correct
65 Correct 0 ms 1556 KB Output is correct
66 Correct 0 ms 1556 KB Output is correct
67 Correct 0 ms 1556 KB Output is correct
68 Correct 0 ms 1556 KB Output is correct
69 Correct 0 ms 1556 KB Output is correct
70 Correct 0 ms 1556 KB Output is correct
71 Correct 0 ms 1556 KB Output is correct
72 Correct 0 ms 1556 KB Output is correct
73 Correct 0 ms 1556 KB Output is correct
74 Correct 0 ms 1556 KB Output is correct
75 Correct 0 ms 1556 KB Output is correct
76 Correct 0 ms 1556 KB Output is correct
77 Correct 0 ms 1556 KB Output is correct
78 Correct 0 ms 1556 KB Output is correct
79 Correct 4 ms 1556 KB Output is correct
80 Correct 0 ms 1556 KB Output is correct
81 Correct 0 ms 1556 KB Output is correct
82 Correct 0 ms 1556 KB Output is correct
83 Correct 0 ms 1556 KB Output is correct
84 Correct 0 ms 1556 KB Output is correct
85 Correct 0 ms 1556 KB Output is correct
86 Correct 0 ms 1556 KB Output is correct
87 Correct 0 ms 1556 KB Output is correct
88 Correct 0 ms 1556 KB Output is correct
89 Correct 0 ms 1556 KB Output is correct
90 Correct 0 ms 1556 KB Output is correct
91 Correct 0 ms 1556 KB Output is correct
92 Correct 0 ms 1556 KB Output is correct
93 Correct 0 ms 1556 KB Output is correct
94 Correct 0 ms 1556 KB Output is correct
95 Correct 0 ms 1556 KB Output is correct
96 Correct 0 ms 1556 KB Output is correct
97 Correct 0 ms 1556 KB Output is correct
98 Correct 0 ms 1556 KB Output is correct
99 Correct 0 ms 1556 KB Output is correct
100 Correct 0 ms 1556 KB Output is correct