답안 #545352

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
545352 2022-04-04T10:32:51 Z leaked Copy and Paste 3 (JOI22_copypaste3) C++14
25 / 100
172 ms 129252 KB
#include <bits/stdc++.h>

#define f first
#define s second
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pb push_back
#define sz(x) (int)(x).size()
#define pw(x) (1LL<<(x))
#define fast_resp ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef pair<int,ll> pil;
template<class T> bool umin(T &a,const T &b){return (a>b?a=b,1:0);}
template<class T> bool umax(T &a,const T &b){return (a<b?a=b,1:0);}
const ll inf=1e18;
const int N=2e2+1;
ll dp[N][N][N];
///l,r,prefix
signed main(){
    fast_resp;
    int n;
    string s;
    cin>>n>>s;
    int a,b,c;
    cin>>a>>b>>c;
    for(int i=0;i<n;i++){
        for(int j=i;j<n;j++){
            for(int k=0;k<=j-i+1;k++)
                dp[i][j][k]=inf;
        }
    }
    for(int d=1;d<=n;d++){
        for(int l=0;l+d-1<n;l++){
            int r=l+d-1;
            if(l==r) dp[l][r][0]=a;
            for(int k=0;k<=r-l+1;k++){
//                    if(k && l+k<n)
//                        umin(dp[l][r][k],dp[l+k][r][0]+dp[l][l+k-1][0]+b);
                if(r-k+1>=l+k && s.substr(l,k)==s.substr(r-k+1,k)){
                    umin(dp[l][r][k],dp[l][r-k][k]+c);
//                    cout<<"W "<<k<<" "<<' '<<l<<' '<<r<<' '<<dp[l][r][k]<<endl;
                }
                umin(dp[l][r][r-l+1],dp[l][r][k]+b+c);
                if(l)
                    umin(dp[l-1][r][0],dp[l][r][k]+a);
                if(r+1<n)
                    umin(dp[l][r+1][k],dp[l][r][k]+a);
                umin(dp[l][r][0],dp[l][r][k]);
            }
//            cout<<dp[2][4][3]<<endl;
        }
    }
//    cout<<dp[2][4][3]<<endl;
    ll ans=inf;
    for(int i=0;i<=n;i++)
        umin(ans,dp[0][n-1][i]);
    cout<<ans;
    return 0;
}
/*

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 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 Runtime error 172 ms 129252 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 596 KB Output is correct
13 Correct 0 ms 596 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 212 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 1108 KB Output is correct
22 Correct 1 ms 1108 KB Output is correct
23 Correct 1 ms 1108 KB Output is correct
24 Correct 1 ms 1108 KB Output is correct
25 Correct 1 ms 1108 KB Output is correct
26 Correct 1 ms 1108 KB Output is correct
27 Correct 1 ms 1108 KB Output is correct
28 Correct 1 ms 1108 KB Output is correct
29 Correct 1 ms 1056 KB Output is correct
30 Correct 1 ms 1108 KB Output is correct
31 Correct 1 ms 1108 KB Output is correct
32 Correct 1 ms 1108 KB Output is correct
33 Correct 1 ms 1108 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 464 KB Output is correct
36 Correct 0 ms 340 KB Output is correct
37 Correct 0 ms 340 KB Output is correct
38 Correct 0 ms 468 KB Output is correct
39 Correct 1 ms 1108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 596 KB Output is correct
13 Correct 0 ms 596 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 212 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 1108 KB Output is correct
22 Correct 1 ms 1108 KB Output is correct
23 Correct 1 ms 1108 KB Output is correct
24 Correct 1 ms 1108 KB Output is correct
25 Correct 1 ms 1108 KB Output is correct
26 Correct 1 ms 1108 KB Output is correct
27 Correct 1 ms 1108 KB Output is correct
28 Correct 1 ms 1108 KB Output is correct
29 Correct 1 ms 1056 KB Output is correct
30 Correct 1 ms 1108 KB Output is correct
31 Correct 1 ms 1108 KB Output is correct
32 Correct 1 ms 1108 KB Output is correct
33 Correct 1 ms 1108 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 464 KB Output is correct
36 Correct 0 ms 340 KB Output is correct
37 Correct 0 ms 340 KB Output is correct
38 Correct 0 ms 468 KB Output is correct
39 Correct 1 ms 1108 KB Output is correct
40 Correct 5 ms 6356 KB Output is correct
41 Correct 50 ms 32596 KB Output is correct
42 Correct 50 ms 32568 KB Output is correct
43 Correct 53 ms 32620 KB Output is correct
44 Correct 55 ms 32620 KB Output is correct
45 Correct 49 ms 32616 KB Output is correct
46 Correct 49 ms 32620 KB Output is correct
47 Correct 54 ms 32636 KB Output is correct
48 Correct 49 ms 32596 KB Output is correct
49 Correct 51 ms 32596 KB Output is correct
50 Correct 54 ms 32620 KB Output is correct
51 Correct 53 ms 32616 KB Output is correct
52 Correct 50 ms 32556 KB Output is correct
53 Correct 49 ms 32596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 596 KB Output is correct
13 Correct 0 ms 596 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 212 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 1108 KB Output is correct
22 Correct 1 ms 1108 KB Output is correct
23 Correct 1 ms 1108 KB Output is correct
24 Correct 1 ms 1108 KB Output is correct
25 Correct 1 ms 1108 KB Output is correct
26 Correct 1 ms 1108 KB Output is correct
27 Correct 1 ms 1108 KB Output is correct
28 Correct 1 ms 1108 KB Output is correct
29 Correct 1 ms 1056 KB Output is correct
30 Correct 1 ms 1108 KB Output is correct
31 Correct 1 ms 1108 KB Output is correct
32 Correct 1 ms 1108 KB Output is correct
33 Correct 1 ms 1108 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 464 KB Output is correct
36 Correct 0 ms 340 KB Output is correct
37 Correct 0 ms 340 KB Output is correct
38 Correct 0 ms 468 KB Output is correct
39 Correct 1 ms 1108 KB Output is correct
40 Correct 5 ms 6356 KB Output is correct
41 Correct 50 ms 32596 KB Output is correct
42 Correct 50 ms 32568 KB Output is correct
43 Correct 53 ms 32620 KB Output is correct
44 Correct 55 ms 32620 KB Output is correct
45 Correct 49 ms 32616 KB Output is correct
46 Correct 49 ms 32620 KB Output is correct
47 Correct 54 ms 32636 KB Output is correct
48 Correct 49 ms 32596 KB Output is correct
49 Correct 51 ms 32596 KB Output is correct
50 Correct 54 ms 32620 KB Output is correct
51 Correct 53 ms 32616 KB Output is correct
52 Correct 50 ms 32556 KB Output is correct
53 Correct 49 ms 32596 KB Output is correct
54 Runtime error 79 ms 129252 KB Execution killed with signal 11
55 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 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 Runtime error 172 ms 129252 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -