# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3339 | pichulia | 일도양단! (kriii1_1) | C++98 | 4 ms | 1556 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>
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 |
---|---|---|---|---|
Fetching results... |