| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 938580 | Pannda | Copy and Paste 3 (JOI22_copypaste3) | C++17 | 1638 ms | 74076 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
string s;
int a, b, c;
cin >> n >> s >> a >> b >> c;
const long long INF = 2e18;
vector<vector<long long>> dp(n + 1, vector<long long>(n + 1, INF));
vector<vector<int>> link(n, vector<int>(n + 1, n));
for (int begin = n - 1; begin >= 0; begin--) {
vector<int> z(n, 0);
for (int i = begin + 1, l = 0, r = 0; i < n; i++) {
while (s[begin + z[i]] == s[i + z[i]]) z[i]++;
}
dp[begin][begin] = 0;
for (int len = 1; len <= n - begin; len++) {
dp[begin][begin + len] = min(dp[begin][begin + len], dp[begin][begin + len - 1] + a);
dp[begin][begin + len] = min(dp[begin][begin + len], dp[begin + 1][begin + len] + a);
link[begin][len] = n;
for (int j = begin + len; j < n; j++) {
if (z[j] >= len) {
link[begin][len] = j;
break;
}
}
int cur = link[begin][len];
int cnt = 1;
while (cur < n) {
cnt++;
dp[begin][cur + len] = min(dp[begin][cur + len], dp[begin][begin + len] + b + 1LL * cnt * c + 1LL * (cur + len - begin - len * cnt) * a);
cur = link[cur][len];
}
}
}
cout << dp[0][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... | ||||
