Submission #719645

# Submission time Handle Problem Language Result Execution time Memory
719645 2023-04-06T12:34:08 Z Abrar_Al_Samit Copy and Paste 3 (JOI22_copypaste3) C++17
25 / 100
3000 ms 788 KB
#include<bits/stdc++.h>
using namespace std;

const int nax = 203;
const long long INF = 1e18;

int n;
string s;
long long A, B, C;
long long dp[nax][nax];

long long solve(int i, int j) {
	long long &ret = dp[i][j];
	if(ret!=-1) return ret;
	if(i==j) return A;

	ret = min((j-i+1) * A, solve(i+1, j) + A);

	for(int k=1; k<j-i+1; ++k) {
		int cnt = 0;
		int p = i;
		while(p+k-1<=j) {
			if(s.substr(i, k)==s.substr(p, k)) {
				++cnt;
				p += k;
			} else ++p;
		}


		long long cur = solve(i, i+k-1) + B;
		cur += cnt * C;
		cur += ((j-i+1) - cnt * k) * A;

		ret = min(ret, cur);

	}
	return ret;
}
void PlayGround() {
	cin>>n>>s>>A>>B>>C;

	memset(dp, -1, sizeof dp);
	s = '@' + s;


	cout<<solve(1, n)<<'\n';

	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	PlayGround();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 0 ms 596 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Incorrect 972 ms 736 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 0 ms 596 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 1 ms 720 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 596 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 596 KB Output is correct
18 Correct 1 ms 596 KB Output is correct
19 Correct 1 ms 596 KB Output is correct
20 Correct 1 ms 596 KB Output is correct
21 Correct 1 ms 596 KB Output is correct
22 Correct 1 ms 596 KB Output is correct
23 Correct 1 ms 596 KB Output is correct
24 Correct 1 ms 596 KB Output is correct
25 Correct 1 ms 596 KB Output is correct
26 Correct 2 ms 596 KB Output is correct
27 Correct 1 ms 596 KB Output is correct
28 Correct 1 ms 596 KB Output is correct
29 Correct 1 ms 596 KB Output is correct
30 Correct 1 ms 596 KB Output is correct
31 Correct 1 ms 596 KB Output is correct
32 Correct 1 ms 596 KB Output is correct
33 Correct 1 ms 596 KB Output is correct
34 Correct 0 ms 596 KB Output is correct
35 Correct 1 ms 592 KB Output is correct
36 Correct 1 ms 596 KB Output is correct
37 Correct 1 ms 596 KB Output is correct
38 Correct 0 ms 596 KB Output is correct
39 Correct 1 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 0 ms 596 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 1 ms 720 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 596 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 596 KB Output is correct
18 Correct 1 ms 596 KB Output is correct
19 Correct 1 ms 596 KB Output is correct
20 Correct 1 ms 596 KB Output is correct
21 Correct 1 ms 596 KB Output is correct
22 Correct 1 ms 596 KB Output is correct
23 Correct 1 ms 596 KB Output is correct
24 Correct 1 ms 596 KB Output is correct
25 Correct 1 ms 596 KB Output is correct
26 Correct 2 ms 596 KB Output is correct
27 Correct 1 ms 596 KB Output is correct
28 Correct 1 ms 596 KB Output is correct
29 Correct 1 ms 596 KB Output is correct
30 Correct 1 ms 596 KB Output is correct
31 Correct 1 ms 596 KB Output is correct
32 Correct 1 ms 596 KB Output is correct
33 Correct 1 ms 596 KB Output is correct
34 Correct 0 ms 596 KB Output is correct
35 Correct 1 ms 592 KB Output is correct
36 Correct 1 ms 596 KB Output is correct
37 Correct 1 ms 596 KB Output is correct
38 Correct 0 ms 596 KB Output is correct
39 Correct 1 ms 596 KB Output is correct
40 Correct 41 ms 640 KB Output is correct
41 Correct 228 ms 672 KB Output is correct
42 Correct 1511 ms 676 KB Output is correct
43 Correct 1558 ms 716 KB Output is correct
44 Correct 1587 ms 700 KB Output is correct
45 Correct 1540 ms 668 KB Output is correct
46 Correct 1522 ms 664 KB Output is correct
47 Correct 858 ms 668 KB Output is correct
48 Correct 1231 ms 668 KB Output is correct
49 Correct 1214 ms 664 KB Output is correct
50 Correct 1232 ms 788 KB Output is correct
51 Correct 893 ms 668 KB Output is correct
52 Correct 888 ms 716 KB Output is correct
53 Correct 1493 ms 672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 0 ms 596 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 1 ms 720 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 596 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 596 KB Output is correct
18 Correct 1 ms 596 KB Output is correct
19 Correct 1 ms 596 KB Output is correct
20 Correct 1 ms 596 KB Output is correct
21 Correct 1 ms 596 KB Output is correct
22 Correct 1 ms 596 KB Output is correct
23 Correct 1 ms 596 KB Output is correct
24 Correct 1 ms 596 KB Output is correct
25 Correct 1 ms 596 KB Output is correct
26 Correct 2 ms 596 KB Output is correct
27 Correct 1 ms 596 KB Output is correct
28 Correct 1 ms 596 KB Output is correct
29 Correct 1 ms 596 KB Output is correct
30 Correct 1 ms 596 KB Output is correct
31 Correct 1 ms 596 KB Output is correct
32 Correct 1 ms 596 KB Output is correct
33 Correct 1 ms 596 KB Output is correct
34 Correct 0 ms 596 KB Output is correct
35 Correct 1 ms 592 KB Output is correct
36 Correct 1 ms 596 KB Output is correct
37 Correct 1 ms 596 KB Output is correct
38 Correct 0 ms 596 KB Output is correct
39 Correct 1 ms 596 KB Output is correct
40 Correct 41 ms 640 KB Output is correct
41 Correct 228 ms 672 KB Output is correct
42 Correct 1511 ms 676 KB Output is correct
43 Correct 1558 ms 716 KB Output is correct
44 Correct 1587 ms 700 KB Output is correct
45 Correct 1540 ms 668 KB Output is correct
46 Correct 1522 ms 664 KB Output is correct
47 Correct 858 ms 668 KB Output is correct
48 Correct 1231 ms 668 KB Output is correct
49 Correct 1214 ms 664 KB Output is correct
50 Correct 1232 ms 788 KB Output is correct
51 Correct 893 ms 668 KB Output is correct
52 Correct 888 ms 716 KB Output is correct
53 Correct 1493 ms 672 KB Output is correct
54 Execution timed out 3049 ms 668 KB Time limit exceeded
55 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 0 ms 596 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Incorrect 972 ms 736 KB Output isn't correct
14 Halted 0 ms 0 KB -