| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 568025 | dantoh000 | Copy and Paste 3 (JOI22_copypaste3) | C++14 | 3078 ms | 41300 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000000000;
int n;
string s;
int a,b,c;
int dp[4505][4505];
int hsh[4505][4505];
int mod = 1000000007;
int GRP[4505];
int H = 29;
map<int, vector<int> > groups;
main(){
scanf("%lld",&n);
cin >> s;
scanf("%lld%lld%lld",&a,&b,&c);
for (int i = 0; i < n; i++){
hsh[i][i] = 0;
for (int j = i+1; j <= n; j++){
hsh[i][j] = (hsh[i][j-1]*H + (s[j-1]-'a'+1))%mod;
}
}
for (int i = 0; i <= n; i++){
dp[i][i] = 0;
for (int j = i+1; j <= n; j++){
dp[i][j] = INF;
}
}
for (int i = 1; i <= n; i++){
for (int j = 0; j+i <= n; j++){
dp[j][j+i] = min(dp[j][j+i], min(dp[j+1][j+i], dp[j][j+i-1]) + a);
}
if (i <= n/2){
groups.clear();
for (int j = 0; j+i <= n; j++){
GRP[j] = hsh[j][j+i];
groups[GRP[j]].push_back(j);
}
for (int j = 0; j+i <= n; j++){
int G = GRP[j];
auto cur = j;
int idx = 0;
int ct = 0;
int dpValue = dp[j][j+i];
while (true){
ct++;
int L = j;
int R = cur + i;
dp[L][R] = min(dp[L][R], dpValue + b + ct*c + (R-L - i*ct)*a);
while (idx < groups[G].size() && groups[G][idx] < R) idx++;
if (idx == groups[G].size()) break;
cur = groups[G][idx];
}
}
}
}
printf("%lld\n",dp[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... | ||||
