답안 #887539

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
887539 2023-12-14T17:37:36 Z Ahmed57 Copy and Paste 3 (JOI22_copypaste3) C++17
25 / 100
862 ms 129904 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
long long n,a,b,c;string s;
int lcp[201][201];
long long dp[201][201][201];
long long solve(int i,int l,int r){
	if(l==0&&r==n){
		return 0;
	}
	if(i==n){
		return 1e18;
	}
	if(dp[i][l][r]!=-1)return dp[i][l][r];
	long long cost = 0 , j = 0;
	long long c1 = solve(i+1,l,r);
	for(j = i;j<n;){
        int lol = (r-l<=lcp[j][l]?r-l:0);
        if(lol==0){
        	cost+=a;
        	if(j+1-i>r-l)c1 = min(c1,solve(0,i,j+1)+cost+b);
        	j++;
        	continue;
        }
        for(long long e = j+1;e<min(n+1,lol+j);e++){
            if(e-i>r-l)c1 = min(c1,solve(0,i,e)+cost+(e-j)*a+b);
        }
        cost+=min((r-l)*a,c);
        if(min(n,lol+j)-i>r-l)c1 = min(c1,solve(0,i,min(n,lol+j))+cost+b);
        j+=r-l;
	}
	return dp[i][l][r] = c1;
}
signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>s>>a>>b>>c;
	memset(dp,-1,sizeof dp);
	for(int i = 0;i<n;i++){
		for(int j = 0;j<n;j++){
			for(int k = 0;k<min(n-i,n-j);k++){
				if(s[i+k]==s[j+k]){
					lcp[i][j]++;
				}else break;
			}
		}
	}
	cout<<solve(0,0,0)-b<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 64092 KB Output is correct
2 Correct 8 ms 64092 KB Output is correct
3 Correct 8 ms 64172 KB Output is correct
4 Correct 8 ms 64092 KB Output is correct
5 Correct 8 ms 64092 KB Output is correct
6 Correct 8 ms 64092 KB Output is correct
7 Correct 8 ms 64212 KB Output is correct
8 Correct 8 ms 64092 KB Output is correct
9 Correct 8 ms 64208 KB Output is correct
10 Correct 8 ms 64092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 64092 KB Output is correct
2 Correct 8 ms 64156 KB Output is correct
3 Runtime error 259 ms 129904 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 64092 KB Output is correct
2 Correct 8 ms 64092 KB Output is correct
3 Correct 8 ms 64172 KB Output is correct
4 Correct 8 ms 64092 KB Output is correct
5 Correct 8 ms 64092 KB Output is correct
6 Correct 8 ms 64092 KB Output is correct
7 Correct 8 ms 64212 KB Output is correct
8 Correct 8 ms 64092 KB Output is correct
9 Correct 8 ms 64208 KB Output is correct
10 Correct 8 ms 64092 KB Output is correct
11 Correct 8 ms 64088 KB Output is correct
12 Correct 8 ms 64092 KB Output is correct
13 Correct 8 ms 64208 KB Output is correct
14 Correct 8 ms 64088 KB Output is correct
15 Correct 8 ms 64092 KB Output is correct
16 Correct 8 ms 64092 KB Output is correct
17 Correct 8 ms 64092 KB Output is correct
18 Correct 8 ms 64092 KB Output is correct
19 Correct 8 ms 64196 KB Output is correct
20 Correct 8 ms 64088 KB Output is correct
21 Correct 9 ms 64092 KB Output is correct
22 Correct 9 ms 64196 KB Output is correct
23 Correct 9 ms 64088 KB Output is correct
24 Correct 9 ms 64088 KB Output is correct
25 Correct 10 ms 64092 KB Output is correct
26 Correct 9 ms 64228 KB Output is correct
27 Correct 8 ms 64184 KB Output is correct
28 Correct 9 ms 64092 KB Output is correct
29 Correct 9 ms 64092 KB Output is correct
30 Correct 9 ms 64092 KB Output is correct
31 Correct 8 ms 64164 KB Output is correct
32 Correct 9 ms 64384 KB Output is correct
33 Correct 9 ms 64092 KB Output is correct
34 Correct 8 ms 64092 KB Output is correct
35 Correct 8 ms 64208 KB Output is correct
36 Correct 8 ms 64092 KB Output is correct
37 Correct 8 ms 64148 KB Output is correct
38 Correct 8 ms 64088 KB Output is correct
39 Correct 9 ms 64092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 64092 KB Output is correct
2 Correct 8 ms 64092 KB Output is correct
3 Correct 8 ms 64172 KB Output is correct
4 Correct 8 ms 64092 KB Output is correct
5 Correct 8 ms 64092 KB Output is correct
6 Correct 8 ms 64092 KB Output is correct
7 Correct 8 ms 64212 KB Output is correct
8 Correct 8 ms 64092 KB Output is correct
9 Correct 8 ms 64208 KB Output is correct
10 Correct 8 ms 64092 KB Output is correct
11 Correct 8 ms 64088 KB Output is correct
12 Correct 8 ms 64092 KB Output is correct
13 Correct 8 ms 64208 KB Output is correct
14 Correct 8 ms 64088 KB Output is correct
15 Correct 8 ms 64092 KB Output is correct
16 Correct 8 ms 64092 KB Output is correct
17 Correct 8 ms 64092 KB Output is correct
18 Correct 8 ms 64092 KB Output is correct
19 Correct 8 ms 64196 KB Output is correct
20 Correct 8 ms 64088 KB Output is correct
21 Correct 9 ms 64092 KB Output is correct
22 Correct 9 ms 64196 KB Output is correct
23 Correct 9 ms 64088 KB Output is correct
24 Correct 9 ms 64088 KB Output is correct
25 Correct 10 ms 64092 KB Output is correct
26 Correct 9 ms 64228 KB Output is correct
27 Correct 8 ms 64184 KB Output is correct
28 Correct 9 ms 64092 KB Output is correct
29 Correct 9 ms 64092 KB Output is correct
30 Correct 9 ms 64092 KB Output is correct
31 Correct 8 ms 64164 KB Output is correct
32 Correct 9 ms 64384 KB Output is correct
33 Correct 9 ms 64092 KB Output is correct
34 Correct 8 ms 64092 KB Output is correct
35 Correct 8 ms 64208 KB Output is correct
36 Correct 8 ms 64092 KB Output is correct
37 Correct 8 ms 64148 KB Output is correct
38 Correct 8 ms 64088 KB Output is correct
39 Correct 9 ms 64092 KB Output is correct
40 Correct 39 ms 64604 KB Output is correct
41 Correct 806 ms 66852 KB Output is correct
42 Correct 812 ms 66856 KB Output is correct
43 Correct 775 ms 66856 KB Output is correct
44 Correct 776 ms 66856 KB Output is correct
45 Correct 807 ms 66856 KB Output is correct
46 Correct 759 ms 66856 KB Output is correct
47 Correct 820 ms 66856 KB Output is correct
48 Correct 780 ms 66856 KB Output is correct
49 Correct 793 ms 66896 KB Output is correct
50 Correct 862 ms 67112 KB Output is correct
51 Correct 796 ms 66860 KB Output is correct
52 Correct 804 ms 66852 KB Output is correct
53 Correct 778 ms 66852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 64092 KB Output is correct
2 Correct 8 ms 64092 KB Output is correct
3 Correct 8 ms 64172 KB Output is correct
4 Correct 8 ms 64092 KB Output is correct
5 Correct 8 ms 64092 KB Output is correct
6 Correct 8 ms 64092 KB Output is correct
7 Correct 8 ms 64212 KB Output is correct
8 Correct 8 ms 64092 KB Output is correct
9 Correct 8 ms 64208 KB Output is correct
10 Correct 8 ms 64092 KB Output is correct
11 Correct 8 ms 64088 KB Output is correct
12 Correct 8 ms 64092 KB Output is correct
13 Correct 8 ms 64208 KB Output is correct
14 Correct 8 ms 64088 KB Output is correct
15 Correct 8 ms 64092 KB Output is correct
16 Correct 8 ms 64092 KB Output is correct
17 Correct 8 ms 64092 KB Output is correct
18 Correct 8 ms 64092 KB Output is correct
19 Correct 8 ms 64196 KB Output is correct
20 Correct 8 ms 64088 KB Output is correct
21 Correct 9 ms 64092 KB Output is correct
22 Correct 9 ms 64196 KB Output is correct
23 Correct 9 ms 64088 KB Output is correct
24 Correct 9 ms 64088 KB Output is correct
25 Correct 10 ms 64092 KB Output is correct
26 Correct 9 ms 64228 KB Output is correct
27 Correct 8 ms 64184 KB Output is correct
28 Correct 9 ms 64092 KB Output is correct
29 Correct 9 ms 64092 KB Output is correct
30 Correct 9 ms 64092 KB Output is correct
31 Correct 8 ms 64164 KB Output is correct
32 Correct 9 ms 64384 KB Output is correct
33 Correct 9 ms 64092 KB Output is correct
34 Correct 8 ms 64092 KB Output is correct
35 Correct 8 ms 64208 KB Output is correct
36 Correct 8 ms 64092 KB Output is correct
37 Correct 8 ms 64148 KB Output is correct
38 Correct 8 ms 64088 KB Output is correct
39 Correct 9 ms 64092 KB Output is correct
40 Correct 39 ms 64604 KB Output is correct
41 Correct 806 ms 66852 KB Output is correct
42 Correct 812 ms 66856 KB Output is correct
43 Correct 775 ms 66856 KB Output is correct
44 Correct 776 ms 66856 KB Output is correct
45 Correct 807 ms 66856 KB Output is correct
46 Correct 759 ms 66856 KB Output is correct
47 Correct 820 ms 66856 KB Output is correct
48 Correct 780 ms 66856 KB Output is correct
49 Correct 793 ms 66896 KB Output is correct
50 Correct 862 ms 67112 KB Output is correct
51 Correct 796 ms 66860 KB Output is correct
52 Correct 804 ms 66852 KB Output is correct
53 Correct 778 ms 66852 KB Output is correct
54 Runtime error 72 ms 129876 KB Execution killed with signal 11
55 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 64092 KB Output is correct
2 Correct 8 ms 64092 KB Output is correct
3 Correct 8 ms 64172 KB Output is correct
4 Correct 8 ms 64092 KB Output is correct
5 Correct 8 ms 64092 KB Output is correct
6 Correct 8 ms 64092 KB Output is correct
7 Correct 8 ms 64212 KB Output is correct
8 Correct 8 ms 64092 KB Output is correct
9 Correct 8 ms 64208 KB Output is correct
10 Correct 8 ms 64092 KB Output is correct
11 Correct 8 ms 64092 KB Output is correct
12 Correct 8 ms 64156 KB Output is correct
13 Runtime error 259 ms 129904 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -