| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 556068 | 600Mihnea | Copy and Paste 3 (JOI22_copypaste3) | C++17 | 3060 ms | 19816 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
bool home = 1;
using namespace std;
typedef long long ll;
const int N=2500+7;
const ll INF=(ll)1e18+7;
int n;
int v[N];
int lcp[N][N];
ll a, b, c, dp[N][N];
signed main() {
#ifdef ONLINE_JUDGE
home = 0;
#endif
home=0;
if (home) {
freopen("I_am_iron_man", "r", stdin);
}
else {
ios::sync_with_stdio(0); cin.tie(0);
}
cin>>n;
{
string str;
cin>>str;
assert((int)str.size()==n);
for(int i=1;i<=n;i++){
v[i]=str[i-1]-'a';
assert(0<=v[i]&&v[i]<26);
}
cin>>a>>b>>c;
}
for (int i=n;i>=1;i--) {
for (int j=n;j>=1;j--) {
if (v[i]==v[j]){
lcp[i][j]=1+lcp[i+1][j+1];
}
}
}
for (int l=n;l>=1;l--) {
for (int r=l;r<=n;r++) {
dp[l][r]=a*(r-l+1);
for (int i=l;i<=r;i++){
for(int j=i;j<=r;j++){
int len=j-i+1,cnt=0;
int k=l;
while (k+len-1<=r) {
if (lcp[k][i]>=len) {
k+=len;
cnt++;
}else{
k++;
}
}
dp[l][r]=min(dp[l][r],dp[i][j]+b+c*cnt+a*((r-l+1)-cnt*len));
}
}
}
}
cout<<dp[1][n]<<"\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... | ||||
