답안 #715958

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
715958 2023-03-28T15:25:43 Z Darren0724 Copy and Paste 3 (JOI22_copypaste3) C++17
25 / 100
3000 ms 52788 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
#define x first
#define y second
#define endl '\n'
const int K=29,mod=1234567891;
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;cin>>n;
    vector<char> v(n+1);
    for(int i=1;i<=n;i++){
        cin>>v[i];
    }
    int A,B,C;cin>>A>>B>>C;
    vector<vector<int>> h(n+2,vector<int>(n+2));
    for(int i=1;i<=n;i++){
        for(int j=i;j<=n;j++){
            h[i][j]=h[i][j-1]*K+v[j]-'a'+1;
        }
    }
    vector<vector<int>> dp(n+2,vector<int>(n+2));
    for(int i=1;i<=n;i++){
        for(int j=1;j+i-1<=n;j++){
            int k=j+i-1;
            //cout<<j<<' '<<k<<endl;
            dp[j][k]=min(dp[j+1][k],dp[j][k-1])+A;
            for(int p=1;p<i;p++){
                int cnt=0,cnt1=0;
                int j1=j;
                while(j1<=k){
                    if(j1+p-1<=k&&h[j][j+p-1]==h[j1][j1+p-1]){
                        cnt++;
                        j1=j1+p;
                    }
                    else{
                        cnt1++;
                        j1++;
                    }
                }
                dp[j][k]=min(dp[j][k],dp[j][j+p-1]+A*cnt1+B+C*cnt);
            }
        }
    }
    cout<<dp[1][n]<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Execution timed out 3061 ms 52788 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 216 KB Output is correct
16 Correct 1 ms 224 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 1 ms 224 KB Output is correct
21 Correct 1 ms 220 KB Output is correct
22 Correct 1 ms 328 KB Output is correct
23 Correct 1 ms 352 KB Output is correct
24 Correct 1 ms 216 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 320 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 448 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 320 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 216 KB Output is correct
16 Correct 1 ms 224 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 1 ms 224 KB Output is correct
21 Correct 1 ms 220 KB Output is correct
22 Correct 1 ms 328 KB Output is correct
23 Correct 1 ms 352 KB Output is correct
24 Correct 1 ms 216 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 320 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 448 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 320 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 352 KB Output is correct
40 Correct 5 ms 456 KB Output is correct
41 Correct 42 ms 868 KB Output is correct
42 Correct 108 ms 968 KB Output is correct
43 Correct 94 ms 952 KB Output is correct
44 Correct 92 ms 972 KB Output is correct
45 Correct 105 ms 960 KB Output is correct
46 Correct 85 ms 980 KB Output is correct
47 Correct 75 ms 960 KB Output is correct
48 Correct 82 ms 952 KB Output is correct
49 Correct 89 ms 960 KB Output is correct
50 Correct 88 ms 852 KB Output is correct
51 Correct 84 ms 956 KB Output is correct
52 Correct 84 ms 956 KB Output is correct
53 Correct 86 ms 960 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 216 KB Output is correct
16 Correct 1 ms 224 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 1 ms 224 KB Output is correct
21 Correct 1 ms 220 KB Output is correct
22 Correct 1 ms 328 KB Output is correct
23 Correct 1 ms 352 KB Output is correct
24 Correct 1 ms 216 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 320 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 448 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 320 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 352 KB Output is correct
40 Correct 5 ms 456 KB Output is correct
41 Correct 42 ms 868 KB Output is correct
42 Correct 108 ms 968 KB Output is correct
43 Correct 94 ms 952 KB Output is correct
44 Correct 92 ms 972 KB Output is correct
45 Correct 105 ms 960 KB Output is correct
46 Correct 85 ms 980 KB Output is correct
47 Correct 75 ms 960 KB Output is correct
48 Correct 82 ms 952 KB Output is correct
49 Correct 89 ms 960 KB Output is correct
50 Correct 88 ms 852 KB Output is correct
51 Correct 84 ms 956 KB Output is correct
52 Correct 84 ms 956 KB Output is correct
53 Correct 86 ms 960 KB Output is correct
54 Correct 2011 ms 3492 KB Output is correct
55 Execution timed out 3036 ms 16084 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Execution timed out 3061 ms 52788 KB Time limit exceeded
14 Halted 0 ms 0 KB -