# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
18472 | eaststar | L 모양의 종이 자르기 (KOI15_cut) | C++14 | 172 ms | 27520 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <algorithm>
using namespace std;
int D[51][51][51][51],E[51][51];
int g(int h,int w){
int i,&s=E[h][w];
if(s)return s;
if(h==w)return s=1;
s=1e4;
for(i=1;i<h;++i)s=min(s,g(i,w)+g(h-i,w));
for(i=1;i<w;++i)s=min(s,g(h,i)+g(h,w-i));
return s;
}
int f(int h1,int w1,int h2,int w2){
int i,&s=D[h1][w1][h2][w2];
if(s)return s;
s=1e4;
for(i=1;i<h2;++i)s=min(s,g(i,w1-w2)+f(h1-i,w1,h2-i,w2));
s=min(s,g(h2,w1-w2)+g(h1-h2,w1));
for(++i;i<h1;++i)s=min(s,f(i,w1,h2,w2)+g(h1-i,w1));
for(i=1;i<w2;++i)s=min(s,g(i,h1-h2)+f(w1-i,h1,w2-i,h2));
s=min(s,g(w2,h1-h2)+g(w1-w2,h1));
for(++i;i<w1;++i)s=min(s,f(i,h1,w2,h2)+g(w1-i,h1));
return D[w1][h1][w2][h2]=s;
}
int main(){
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
printf("%d",f(a,b,c,d));
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |