# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
18030 | gs13068 | L 모양의 종이 자르기 (KOI15_cut) | C++98 | 378 ms | 36840 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<cstdio>
#include<algorithm>
int c[55][55];
int d[55][55][55][55];
int main()
{
int i,j,k,l,t,w,x,y,z;
scanf("%d%d%d%d",&w,&x,&y,&z);
for(i=1;i<=w;i++)for(j=1;j<=x;j++)
{
c[i][j]=1e9;
if(i==j)c[i][j]=1;
for(k=1;k<i;k++)c[i][j]=std::min(c[i][j],c[k][j]+c[i-k][j]);
for(l=1;l<j;l++)c[i][j]=std::min(c[i][j],c[i][l]+c[i][j-l]);
}
for(i=2;i<=w;i++)for(j=2;j<=x;j++)for(k=1;k<i;k++)for(l=1;l<j;l++)
{
d[i][j][k][l]=1e9;
for(t=1;t<k;t++)d[i][j][k][l]=std::min(d[i][j][k][l],d[i-t][j][k-t][l]+c[t][j-l]);
d[i][j][k][l]=std::min(d[i][j][k][l],c[k][j-l]+c[i-k][j]);
for(t=k+1;t<i;t++)d[i][j][k][l]=std::min(d[i][j][k][l],d[t][j][k][l]+c[i-t][j]);
for(t=1;t<l;t++)d[i][j][k][l]=std::min(d[i][j][k][l],d[i][j-t][k][l-t]+c[i-k][t]);
d[i][j][k][l]=std::min(d[i][j][k][l],c[i-k][l]+c[i][j-l]);
for(t=l+1;t<j;t++)d[i][j][k][l]=std::min(d[i][j][k][l],d[i][t][k][l]+c[i][j-t]);
}
printf("%d\n",d[w][x][y][z]);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |