Submission #587575

# Submission time Handle Problem Language Result Execution time Memory
587575 2022-07-02T05:55:31 Z LastRonin Copy and Paste 3 (JOI22_copypaste3) C++14
25 / 100
1652 ms 20048 KB
#pragma GCC optimize("O3")

#include <bits/stdc++.h> 
#define ll long long
#define mp make_pair
#define f first
#define s second
#define pb push_back
#define pill pair<ll, ll>
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;

const int N = 211 + 1;
const ll hsh[2] = {1555555699, 1222222763};
const ll P = 113;

ll n;
string a;
ll dp[N][N], dp2[N];
ll A, B, C;

bool eq[N][N][N];

int main() {
	speed;
	cin >> n;
	cin >> a;
	cin >> A >> B >> C;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			dp[i][j] = 1e15;
			for(int st = 1; st <= n; st++) {
				if(a[i + st - 1] != a[j + st - 1])
					break;
				eq[i][j][st] = 1;
			}
		}
	}
	for(int k = 1; k <= n; k++) {
		for(int i = 0; i + k - 1 < n; i++) {
			dp[i][i + k - 1] = min(dp[i][i + k - 1], A * k + B);
			if(k * A < C)continue;
			for(int j = 0; j < n; j++) {
				for(int z = j; z <= n; z++) {
					dp2[z] = 1e15;	
				}
				dp2[j] = dp[i][i + k - 1];				
				for(int z = j; z < n; z++) {
					if(eq[i][z][k])
						dp2[z + k] = min(dp2[z + k], dp2[z] + C);
					dp2[z + 1] = min(dp2[z + 1], dp2[z] + A);
				}
				for(int z = j + 1; z <= n; z++) {
					dp[j][z - 1] = min(dp[j][z - 1], dp2[z] + B); 
				}
		 	}
    	}
    }
    cout << dp[0][n - 1] - B;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Runtime error 212 ms 20028 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 596 KB Output is correct
22 Correct 2 ms 596 KB Output is correct
23 Correct 1 ms 596 KB Output is correct
24 Correct 2 ms 596 KB Output is correct
25 Correct 2 ms 588 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 596 KB Output is correct
28 Correct 2 ms 596 KB Output is correct
29 Correct 2 ms 596 KB Output is correct
30 Correct 1 ms 588 KB Output is correct
31 Correct 1 ms 596 KB Output is correct
32 Correct 2 ms 596 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 328 KB Output is correct
36 Correct 0 ms 340 KB Output is correct
37 Correct 0 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 2 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 596 KB Output is correct
22 Correct 2 ms 596 KB Output is correct
23 Correct 1 ms 596 KB Output is correct
24 Correct 2 ms 596 KB Output is correct
25 Correct 2 ms 588 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 596 KB Output is correct
28 Correct 2 ms 596 KB Output is correct
29 Correct 2 ms 596 KB Output is correct
30 Correct 1 ms 588 KB Output is correct
31 Correct 1 ms 596 KB Output is correct
32 Correct 2 ms 596 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 328 KB Output is correct
36 Correct 0 ms 340 KB Output is correct
37 Correct 0 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 2 ms 596 KB Output is correct
40 Correct 44 ms 2228 KB Output is correct
41 Correct 1652 ms 9436 KB Output is correct
42 Correct 1285 ms 9324 KB Output is correct
43 Correct 4 ms 9428 KB Output is correct
44 Correct 334 ms 9144 KB Output is correct
45 Correct 1112 ms 7412 KB Output is correct
46 Correct 1165 ms 5616 KB Output is correct
47 Correct 3 ms 8276 KB Output is correct
48 Correct 3 ms 6100 KB Output is correct
49 Correct 3 ms 6868 KB Output is correct
50 Correct 3 ms 6100 KB Output is correct
51 Correct 4 ms 9300 KB Output is correct
52 Correct 1185 ms 9428 KB Output is correct
53 Correct 1165 ms 5552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 596 KB Output is correct
22 Correct 2 ms 596 KB Output is correct
23 Correct 1 ms 596 KB Output is correct
24 Correct 2 ms 596 KB Output is correct
25 Correct 2 ms 588 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 596 KB Output is correct
28 Correct 2 ms 596 KB Output is correct
29 Correct 2 ms 596 KB Output is correct
30 Correct 1 ms 588 KB Output is correct
31 Correct 1 ms 596 KB Output is correct
32 Correct 2 ms 596 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 328 KB Output is correct
36 Correct 0 ms 340 KB Output is correct
37 Correct 0 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 2 ms 596 KB Output is correct
40 Correct 44 ms 2228 KB Output is correct
41 Correct 1652 ms 9436 KB Output is correct
42 Correct 1285 ms 9324 KB Output is correct
43 Correct 4 ms 9428 KB Output is correct
44 Correct 334 ms 9144 KB Output is correct
45 Correct 1112 ms 7412 KB Output is correct
46 Correct 1165 ms 5616 KB Output is correct
47 Correct 3 ms 8276 KB Output is correct
48 Correct 3 ms 6100 KB Output is correct
49 Correct 3 ms 6868 KB Output is correct
50 Correct 3 ms 6100 KB Output is correct
51 Correct 4 ms 9300 KB Output is correct
52 Correct 1185 ms 9428 KB Output is correct
53 Correct 1165 ms 5552 KB Output is correct
54 Runtime error 15 ms 20048 KB Execution killed with signal 11
55 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Runtime error 212 ms 20028 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -