# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
556190 | 600Mihnea | Copy and Paste 3 (JOI22_copypaste3) | C++17 | 1401 ms | 58444 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=1;l<=n;l++) {
for (int r=l;r<=n;r++) {
dp[l][r]=INF;
}
}
for (int l=n;l>=1;l--) {
for (int len=1;l+len<=n;len++) {
vector<int> pivots;
int k=l+len;
while (k+len-1<=n) {
if (lcp[l][k]>=len) {
pivots.push_back(k);
k+=len;
}else{
k++;
}
}
for (int i=0;i<(int) pivots.size();i++) {
int r=pivots[i]+len-1;
dp[l][r]=min(dp[l][r],dp[r-len+1][r]+(i+2)*(c-a*len));
}
}
for (int r=l;r<=n;r++){
dp[l][r]=min(dp[l][r]+a*(r-l+1)+b,min(dp[l+1][r],dp[l][r-1])+a);
}
}
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... |