답안 #556670

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
556670 2022-05-03T14:17:08 Z mosiashvililuka Copy and Paste 3 (JOI22_copypaste3) C++14
100 / 100
577 ms 132060 KB
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,A,B,C,dp[2504][2504],f[2504][2504],g[2504][2504];
string s;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>s;s="0"+s;
	cin>>A>>B>>C;
	for(i=a; i>=1; i--){
		for(j=a; j>i; j--){
			if(s[i]!=s[j]){
				f[i][j]=0;continue;
			}
			f[i][j]=f[i+1][j+1]+1;
		}
	}
	for(i=0; i<=a+1; i++){
		for(j=0; j<=a+1; j++){
			g[i][j]=a+2;
			if(i<=j) dp[i][j]=A*a; else dp[i][j]=0;
		}
	}
	for(i=1; i<=a; i++){
		jj=i+1;
		for(j=i; j<=a; j++){
			if(jj>a) break;
			if(jj<=j||f[i][jj]<j-i+1){
				jj++;j--;
				continue;
			}
			g[i][j-i+1]=jj;
		}
	}
	for(i=a; i>=1; i--){
		for(j=i; j<=a; j++){
			dp[i][j]=min(dp[i][j-1]+A,dp[i][j]);
			dp[i][j]=min(dp[i+1][j]+A,dp[i][j]);
			jj=j-i+1;
			c=i;d=1;
			while(1){
				c=g[c][jj];d++;
				if(c>a) break;
				//cout<<i<<" "<<j<<"   "<<c<<" "<<d<<"\n";
				e=(c+jj-1)-i+1-(d*jj);
				zx=B+C*d+e*A+dp[i][j];
				/*if(dp[i][c+jj-1]>zx){
					cout<<"update: dp["<<i<<"]["<<c+jj-1<<"]"<<"="<<zx<<"      "<<i<<" "<<j<<" "<<c<<" "<<d<<"\n";
				}*/
				dp[i][c+jj-1]=min(dp[i][c+jj-1],zx);
			}
		}
	}
	cout<<dp[1][a];
	return 0;
}
# 결과 실행 시간 메모리 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 340 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 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 243 ms 87940 KB Output is correct
4 Correct 322 ms 100600 KB Output is correct
5 Correct 328 ms 110564 KB Output is correct
6 Correct 536 ms 120788 KB Output is correct
7 Correct 573 ms 131928 KB Output is correct
8 Correct 509 ms 131928 KB Output is correct
9 Correct 577 ms 131836 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 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 720 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 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 340 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 340 KB Output is correct
8 Correct 0 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 468 KB Output is correct
12 Correct 1 ms 468 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 568 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 708 KB Output is correct
22 Correct 1 ms 724 KB Output is correct
23 Correct 1 ms 724 KB Output is correct
24 Correct 1 ms 724 KB Output is correct
25 Correct 1 ms 724 KB Output is correct
26 Correct 1 ms 724 KB Output is correct
27 Correct 1 ms 724 KB Output is correct
28 Correct 1 ms 724 KB Output is correct
29 Correct 1 ms 712 KB Output is correct
30 Correct 1 ms 724 KB Output is correct
31 Correct 1 ms 724 KB Output is correct
32 Correct 1 ms 724 KB Output is correct
33 Correct 1 ms 724 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 0 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 468 KB Output is correct
39 Correct 1 ms 724 KB Output is correct
# 결과 실행 시간 메모리 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 340 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 340 KB Output is correct
8 Correct 0 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 468 KB Output is correct
12 Correct 1 ms 468 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 568 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 708 KB Output is correct
22 Correct 1 ms 724 KB Output is correct
23 Correct 1 ms 724 KB Output is correct
24 Correct 1 ms 724 KB Output is correct
25 Correct 1 ms 724 KB Output is correct
26 Correct 1 ms 724 KB Output is correct
27 Correct 1 ms 724 KB Output is correct
28 Correct 1 ms 724 KB Output is correct
29 Correct 1 ms 712 KB Output is correct
30 Correct 1 ms 724 KB Output is correct
31 Correct 1 ms 724 KB Output is correct
32 Correct 1 ms 724 KB Output is correct
33 Correct 1 ms 724 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 0 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 468 KB Output is correct
39 Correct 1 ms 724 KB Output is correct
40 Correct 1 ms 1492 KB Output is correct
41 Correct 3 ms 3540 KB Output is correct
42 Correct 2 ms 3540 KB Output is correct
43 Correct 3 ms 3540 KB Output is correct
44 Correct 2 ms 3540 KB Output is correct
45 Correct 3 ms 3540 KB Output is correct
46 Correct 2 ms 3540 KB Output is correct
47 Correct 2 ms 3540 KB Output is correct
48 Correct 2 ms 3540 KB Output is correct
49 Correct 2 ms 3540 KB Output is correct
50 Correct 2 ms 3540 KB Output is correct
51 Correct 2 ms 3528 KB Output is correct
52 Correct 2 ms 3540 KB Output is correct
53 Correct 2 ms 3540 KB Output is correct
# 결과 실행 시간 메모리 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 340 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 340 KB Output is correct
8 Correct 0 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 468 KB Output is correct
12 Correct 1 ms 468 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 568 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 708 KB Output is correct
22 Correct 1 ms 724 KB Output is correct
23 Correct 1 ms 724 KB Output is correct
24 Correct 1 ms 724 KB Output is correct
25 Correct 1 ms 724 KB Output is correct
26 Correct 1 ms 724 KB Output is correct
27 Correct 1 ms 724 KB Output is correct
28 Correct 1 ms 724 KB Output is correct
29 Correct 1 ms 712 KB Output is correct
30 Correct 1 ms 724 KB Output is correct
31 Correct 1 ms 724 KB Output is correct
32 Correct 1 ms 724 KB Output is correct
33 Correct 1 ms 724 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 0 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 468 KB Output is correct
39 Correct 1 ms 724 KB Output is correct
40 Correct 1 ms 1492 KB Output is correct
41 Correct 3 ms 3540 KB Output is correct
42 Correct 2 ms 3540 KB Output is correct
43 Correct 3 ms 3540 KB Output is correct
44 Correct 2 ms 3540 KB Output is correct
45 Correct 3 ms 3540 KB Output is correct
46 Correct 2 ms 3540 KB Output is correct
47 Correct 2 ms 3540 KB Output is correct
48 Correct 2 ms 3540 KB Output is correct
49 Correct 2 ms 3540 KB Output is correct
50 Correct 2 ms 3540 KB Output is correct
51 Correct 2 ms 3528 KB Output is correct
52 Correct 2 ms 3540 KB Output is correct
53 Correct 2 ms 3540 KB Output is correct
54 Correct 6 ms 9696 KB Output is correct
55 Correct 51 ms 32024 KB Output is correct
56 Correct 22 ms 31956 KB Output is correct
57 Correct 23 ms 31948 KB Output is correct
58 Correct 25 ms 31956 KB Output is correct
59 Correct 21 ms 31956 KB Output is correct
60 Correct 20 ms 31956 KB Output is correct
61 Correct 21 ms 31956 KB Output is correct
62 Correct 35 ms 32012 KB Output is correct
63 Correct 20 ms 31960 KB Output is correct
64 Correct 23 ms 31948 KB Output is correct
65 Correct 25 ms 31912 KB Output is correct
66 Correct 25 ms 31964 KB Output is correct
67 Correct 19 ms 32032 KB Output is correct
# 결과 실행 시간 메모리 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 340 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 340 KB Output is correct
8 Correct 0 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 468 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 243 ms 87940 KB Output is correct
14 Correct 322 ms 100600 KB Output is correct
15 Correct 328 ms 110564 KB Output is correct
16 Correct 536 ms 120788 KB Output is correct
17 Correct 573 ms 131928 KB Output is correct
18 Correct 509 ms 131928 KB Output is correct
19 Correct 577 ms 131836 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 328 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 1 ms 720 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 468 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 568 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 468 KB Output is correct
37 Correct 0 ms 340 KB Output is correct
38 Correct 1 ms 708 KB Output is correct
39 Correct 1 ms 724 KB Output is correct
40 Correct 1 ms 724 KB Output is correct
41 Correct 1 ms 724 KB Output is correct
42 Correct 1 ms 724 KB Output is correct
43 Correct 1 ms 724 KB Output is correct
44 Correct 1 ms 724 KB Output is correct
45 Correct 1 ms 724 KB Output is correct
46 Correct 1 ms 712 KB Output is correct
47 Correct 1 ms 724 KB Output is correct
48 Correct 1 ms 724 KB Output is correct
49 Correct 1 ms 724 KB Output is correct
50 Correct 1 ms 724 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 0 ms 340 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 1 ms 468 KB Output is correct
56 Correct 1 ms 724 KB Output is correct
57 Correct 1 ms 1492 KB Output is correct
58 Correct 3 ms 3540 KB Output is correct
59 Correct 2 ms 3540 KB Output is correct
60 Correct 3 ms 3540 KB Output is correct
61 Correct 2 ms 3540 KB Output is correct
62 Correct 3 ms 3540 KB Output is correct
63 Correct 2 ms 3540 KB Output is correct
64 Correct 2 ms 3540 KB Output is correct
65 Correct 2 ms 3540 KB Output is correct
66 Correct 2 ms 3540 KB Output is correct
67 Correct 2 ms 3540 KB Output is correct
68 Correct 2 ms 3528 KB Output is correct
69 Correct 2 ms 3540 KB Output is correct
70 Correct 2 ms 3540 KB Output is correct
71 Correct 6 ms 9696 KB Output is correct
72 Correct 51 ms 32024 KB Output is correct
73 Correct 22 ms 31956 KB Output is correct
74 Correct 23 ms 31948 KB Output is correct
75 Correct 25 ms 31956 KB Output is correct
76 Correct 21 ms 31956 KB Output is correct
77 Correct 20 ms 31956 KB Output is correct
78 Correct 21 ms 31956 KB Output is correct
79 Correct 35 ms 32012 KB Output is correct
80 Correct 20 ms 31960 KB Output is correct
81 Correct 23 ms 31948 KB Output is correct
82 Correct 25 ms 31912 KB Output is correct
83 Correct 25 ms 31964 KB Output is correct
84 Correct 19 ms 32032 KB Output is correct
85 Correct 57 ms 68452 KB Output is correct
86 Correct 155 ms 131852 KB Output is correct
87 Correct 117 ms 131936 KB Output is correct
88 Correct 96 ms 131824 KB Output is correct
89 Correct 92 ms 131924 KB Output is correct
90 Correct 103 ms 131856 KB Output is correct
91 Correct 142 ms 132060 KB Output is correct
92 Correct 180 ms 131936 KB Output is correct
93 Correct 98 ms 131944 KB Output is correct
94 Correct 108 ms 131892 KB Output is correct
95 Correct 180 ms 131876 KB Output is correct
96 Correct 163 ms 131876 KB Output is correct
97 Correct 90 ms 131912 KB Output is correct