# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
567735 | tqbfjotld | Copy and Paste 3 (JOI22_copypaste3) | C++14 | 3074 ms | 49540 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
char arr[2505];
int A,B,C;
int mem[2505][2505];
int cntocc(int a, int b, int st, int en){
int cur = b;
int ans = 1;
while (cur+(b-a)<=en){
bool can = true;
for (int x = 0; x<b-a; x++){
if (arr[cur+x]!=arr[a+x]){
can = false;
break;
}
}
if (can){
ans++;
cur += b-a;
}
else{
cur++;
}
}
return ans;
}
int func(int a, int b){
if (mem[a][b]!=-1) return mem[a][b];
if (a==b) return 0;
int ans = func(a+1,b)+A;
for (int x = 1; x<b-a; x++){
int t = func(a,a+x);
int t2 = cntocc(a,a+x,a,b);
ans = min(ans,t+B+t2*C+(b-a-x*t2)*A);
}
//printf("func %lld %lld = %lld\n",a,b,ans);
return mem[a][b] = ans;
}
main(){
int n;
scanf("%lld",&n);
for (int x = 0; x<n; x++){
scanf(" %c",&arr[x]);
}
scanf("%lld%lld%lld",&A,&B,&C);
memset(mem,-1,sizeof(mem));
printf("%lld",func(0,n));
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |