# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
938580 | 2024-03-05T10:29:52 Z | Pannda | Copy and Paste 3 (JOI22_copypaste3) | C++17 | 1638 ms | 74076 KB |
#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'; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 589 ms | 39680 KB | Output is correct |
4 | Correct | 701 ms | 46416 KB | Output is correct |
5 | Correct | 1052 ms | 54324 KB | Output is correct |
6 | Correct | 1270 ms | 63568 KB | Output is correct |
7 | Correct | 1411 ms | 74060 KB | Output is correct |
8 | Correct | 1626 ms | 74064 KB | Output is correct |
9 | Correct | 1638 ms | 74056 KB | Output is correct |
10 | Correct | 0 ms | 344 KB | Output is correct |
11 | Correct | 1 ms | 500 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 0 ms | 348 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 0 ms | 344 KB | Output is correct |
24 | Correct | 0 ms | 348 KB | Output is correct |
25 | Correct | 0 ms | 348 KB | Output is correct |
26 | Correct | 0 ms | 348 KB | Output is correct |
27 | Correct | 0 ms | 348 KB | Output is correct |
28 | Correct | 0 ms | 348 KB | Output is correct |
29 | Correct | 0 ms | 348 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 0 ms | 344 KB | Output is correct |
32 | Correct | 0 ms | 344 KB | Output is correct |
33 | Correct | 0 ms | 348 KB | Output is correct |
34 | Correct | 0 ms | 348 KB | Output is correct |
35 | Correct | 0 ms | 348 KB | Output is correct |
36 | Correct | 0 ms | 348 KB | Output is correct |
37 | Correct | 0 ms | 348 KB | Output is correct |
38 | Correct | 0 ms | 344 KB | Output is correct |
39 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 0 ms | 348 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 0 ms | 344 KB | Output is correct |
24 | Correct | 0 ms | 348 KB | Output is correct |
25 | Correct | 0 ms | 348 KB | Output is correct |
26 | Correct | 0 ms | 348 KB | Output is correct |
27 | Correct | 0 ms | 348 KB | Output is correct |
28 | Correct | 0 ms | 348 KB | Output is correct |
29 | Correct | 0 ms | 348 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 0 ms | 344 KB | Output is correct |
32 | Correct | 0 ms | 344 KB | Output is correct |
33 | Correct | 0 ms | 348 KB | Output is correct |
34 | Correct | 0 ms | 348 KB | Output is correct |
35 | Correct | 0 ms | 348 KB | Output is correct |
36 | Correct | 0 ms | 348 KB | Output is correct |
37 | Correct | 0 ms | 348 KB | Output is correct |
38 | Correct | 0 ms | 344 KB | Output is correct |
39 | Correct | 0 ms | 348 KB | Output is correct |
40 | Correct | 1 ms | 348 KB | Output is correct |
41 | Correct | 2 ms | 860 KB | Output is correct |
42 | Correct | 1 ms | 860 KB | Output is correct |
43 | Correct | 1 ms | 708 KB | Output is correct |
44 | Correct | 1 ms | 860 KB | Output is correct |
45 | Correct | 1 ms | 860 KB | Output is correct |
46 | Correct | 1 ms | 860 KB | Output is correct |
47 | Correct | 1 ms | 860 KB | Output is correct |
48 | Correct | 1 ms | 860 KB | Output is correct |
49 | Correct | 1 ms | 860 KB | Output is correct |
50 | Correct | 1 ms | 860 KB | Output is correct |
51 | Correct | 1 ms | 856 KB | Output is correct |
52 | Correct | 1 ms | 860 KB | Output is correct |
53 | Correct | 1 ms | 856 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 0 ms | 348 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 0 ms | 344 KB | Output is correct |
24 | Correct | 0 ms | 348 KB | Output is correct |
25 | Correct | 0 ms | 348 KB | Output is correct |
26 | Correct | 0 ms | 348 KB | Output is correct |
27 | Correct | 0 ms | 348 KB | Output is correct |
28 | Correct | 0 ms | 348 KB | Output is correct |
29 | Correct | 0 ms | 348 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 0 ms | 344 KB | Output is correct |
32 | Correct | 0 ms | 344 KB | Output is correct |
33 | Correct | 0 ms | 348 KB | Output is correct |
34 | Correct | 0 ms | 348 KB | Output is correct |
35 | Correct | 0 ms | 348 KB | Output is correct |
36 | Correct | 0 ms | 348 KB | Output is correct |
37 | Correct | 0 ms | 348 KB | Output is correct |
38 | Correct | 0 ms | 344 KB | Output is correct |
39 | Correct | 0 ms | 348 KB | Output is correct |
40 | Correct | 1 ms | 348 KB | Output is correct |
41 | Correct | 2 ms | 860 KB | Output is correct |
42 | Correct | 1 ms | 860 KB | Output is correct |
43 | Correct | 1 ms | 708 KB | Output is correct |
44 | Correct | 1 ms | 860 KB | Output is correct |
45 | Correct | 1 ms | 860 KB | Output is correct |
46 | Correct | 1 ms | 860 KB | Output is correct |
47 | Correct | 1 ms | 860 KB | Output is correct |
48 | Correct | 1 ms | 860 KB | Output is correct |
49 | Correct | 1 ms | 860 KB | Output is correct |
50 | Correct | 1 ms | 860 KB | Output is correct |
51 | Correct | 1 ms | 856 KB | Output is correct |
52 | Correct | 1 ms | 860 KB | Output is correct |
53 | Correct | 1 ms | 856 KB | Output is correct |
54 | Correct | 8 ms | 2652 KB | Output is correct |
55 | Correct | 107 ms | 12264 KB | Output is correct |
56 | Correct | 68 ms | 12120 KB | Output is correct |
57 | Correct | 66 ms | 12124 KB | Output is correct |
58 | Correct | 65 ms | 12124 KB | Output is correct |
59 | Correct | 64 ms | 12268 KB | Output is correct |
60 | Correct | 67 ms | 12120 KB | Output is correct |
61 | Correct | 51 ms | 12120 KB | Output is correct |
62 | Correct | 57 ms | 12268 KB | Output is correct |
63 | Correct | 46 ms | 12124 KB | Output is correct |
64 | Correct | 51 ms | 12124 KB | Output is correct |
65 | Correct | 43 ms | 12284 KB | Output is correct |
66 | Correct | 39 ms | 12376 KB | Output is correct |
67 | Correct | 63 ms | 12124 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 344 KB | Output is correct |
13 | Correct | 589 ms | 39680 KB | Output is correct |
14 | Correct | 701 ms | 46416 KB | Output is correct |
15 | Correct | 1052 ms | 54324 KB | Output is correct |
16 | Correct | 1270 ms | 63568 KB | Output is correct |
17 | Correct | 1411 ms | 74060 KB | Output is correct |
18 | Correct | 1626 ms | 74064 KB | Output is correct |
19 | Correct | 1638 ms | 74056 KB | Output is correct |
20 | Correct | 0 ms | 344 KB | Output is correct |
21 | Correct | 1 ms | 500 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 0 ms | 348 KB | Output is correct |
24 | Correct | 0 ms | 348 KB | Output is correct |
25 | Correct | 1 ms | 348 KB | Output is correct |
26 | Correct | 0 ms | 348 KB | Output is correct |
27 | Correct | 0 ms | 348 KB | Output is correct |
28 | Correct | 0 ms | 348 KB | Output is correct |
29 | Correct | 0 ms | 348 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 0 ms | 348 KB | Output is correct |
32 | Correct | 0 ms | 348 KB | Output is correct |
33 | Correct | 0 ms | 348 KB | Output is correct |
34 | Correct | 0 ms | 348 KB | Output is correct |
35 | Correct | 0 ms | 348 KB | Output is correct |
36 | Correct | 0 ms | 348 KB | Output is correct |
37 | Correct | 0 ms | 348 KB | Output is correct |
38 | Correct | 0 ms | 348 KB | Output is correct |
39 | Correct | 0 ms | 348 KB | Output is correct |
40 | Correct | 0 ms | 344 KB | Output is correct |
41 | Correct | 0 ms | 348 KB | Output is correct |
42 | Correct | 0 ms | 348 KB | Output is correct |
43 | Correct | 0 ms | 348 KB | Output is correct |
44 | Correct | 0 ms | 348 KB | Output is correct |
45 | Correct | 0 ms | 348 KB | Output is correct |
46 | Correct | 0 ms | 348 KB | Output is correct |
47 | Correct | 0 ms | 348 KB | Output is correct |
48 | Correct | 0 ms | 344 KB | Output is correct |
49 | Correct | 0 ms | 344 KB | Output is correct |
50 | Correct | 0 ms | 348 KB | Output is correct |
51 | Correct | 0 ms | 348 KB | Output is correct |
52 | Correct | 0 ms | 348 KB | Output is correct |
53 | Correct | 0 ms | 348 KB | Output is correct |
54 | Correct | 0 ms | 348 KB | Output is correct |
55 | Correct | 0 ms | 344 KB | Output is correct |
56 | Correct | 0 ms | 348 KB | Output is correct |
57 | Correct | 1 ms | 348 KB | Output is correct |
58 | Correct | 2 ms | 860 KB | Output is correct |
59 | Correct | 1 ms | 860 KB | Output is correct |
60 | Correct | 1 ms | 708 KB | Output is correct |
61 | Correct | 1 ms | 860 KB | Output is correct |
62 | Correct | 1 ms | 860 KB | Output is correct |
63 | Correct | 1 ms | 860 KB | Output is correct |
64 | Correct | 1 ms | 860 KB | Output is correct |
65 | Correct | 1 ms | 860 KB | Output is correct |
66 | Correct | 1 ms | 860 KB | Output is correct |
67 | Correct | 1 ms | 860 KB | Output is correct |
68 | Correct | 1 ms | 856 KB | Output is correct |
69 | Correct | 1 ms | 860 KB | Output is correct |
70 | Correct | 1 ms | 856 KB | Output is correct |
71 | Correct | 8 ms | 2652 KB | Output is correct |
72 | Correct | 107 ms | 12264 KB | Output is correct |
73 | Correct | 68 ms | 12120 KB | Output is correct |
74 | Correct | 66 ms | 12124 KB | Output is correct |
75 | Correct | 65 ms | 12124 KB | Output is correct |
76 | Correct | 64 ms | 12268 KB | Output is correct |
77 | Correct | 67 ms | 12120 KB | Output is correct |
78 | Correct | 51 ms | 12120 KB | Output is correct |
79 | Correct | 57 ms | 12268 KB | Output is correct |
80 | Correct | 46 ms | 12124 KB | Output is correct |
81 | Correct | 51 ms | 12124 KB | Output is correct |
82 | Correct | 43 ms | 12284 KB | Output is correct |
83 | Correct | 39 ms | 12376 KB | Output is correct |
84 | Correct | 63 ms | 12124 KB | Output is correct |
85 | Correct | 279 ms | 29936 KB | Output is correct |
86 | Correct | 931 ms | 74064 KB | Output is correct |
87 | Correct | 915 ms | 74060 KB | Output is correct |
88 | Correct | 966 ms | 74060 KB | Output is correct |
89 | Correct | 877 ms | 74056 KB | Output is correct |
90 | Correct | 931 ms | 74076 KB | Output is correct |
91 | Correct | 343 ms | 74072 KB | Output is correct |
92 | Correct | 451 ms | 74056 KB | Output is correct |
93 | Correct | 588 ms | 74076 KB | Output is correct |
94 | Correct | 1032 ms | 74060 KB | Output is correct |
95 | Correct | 450 ms | 73808 KB | Output is correct |
96 | Correct | 521 ms | 74056 KB | Output is correct |
97 | Correct | 878 ms | 74060 KB | Output is correct |