답안 #545355

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
545355 2022-04-04T10:42:20 Z leaked Copy and Paste 3 (JOI22_copypaste3) C++14
25 / 100
3000 ms 32404 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=1e3+3;
ll dp[2][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 t=0;t<2;t++){
        for(int j=0;j<N;j++){
            for(int k=0;k<N;k++)
                dp[t][j][k]=inf;
        }
    }
    for(int l=n-1;l>=0;l--){
        int nl=(l%2)^1;
        for(int r=max(l-1,0);r<n;r++){
            for(int k=0;k<=r-l+2;k++)
                dp[nl][r][k]=inf;
        }
        int lt=l%2;
        for(int r=l;r<n;r++){
            if(l==r) dp[lt][r][0]=a;
            for(int k=0;k<=r-l+1;k++){
                if(r-k+1>=l+k && s.substr(l,k)==s.substr(r-k+1,k)){
                    umin(dp[lt][r][k],dp[lt][r-k][k]+c);
                }
                umin(dp[lt][r][r-l+1],dp[lt][r][k]+b+c);
                if(l)
                    umin(dp[nl][r][0],dp[lt][r][k]+a);
                if(r+1<n)
                    umin(dp[lt][r+1][k],dp[lt][r][k]+a);
                umin(dp[lt][r][0],dp[lt][r][k]);
            }
        }
    }
//    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 9 ms 15956 KB Output is correct
2 Correct 9 ms 15956 KB Output is correct
3 Correct 10 ms 15956 KB Output is correct
4 Correct 7 ms 15956 KB Output is correct
5 Correct 7 ms 16008 KB Output is correct
6 Correct 7 ms 15956 KB Output is correct
7 Correct 7 ms 15980 KB Output is correct
8 Correct 7 ms 15956 KB Output is correct
9 Correct 7 ms 15956 KB Output is correct
10 Correct 7 ms 15956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 16036 KB Output is correct
2 Correct 7 ms 15956 KB Output is correct
3 Runtime error 22 ms 32404 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 15956 KB Output is correct
2 Correct 9 ms 15956 KB Output is correct
3 Correct 10 ms 15956 KB Output is correct
4 Correct 7 ms 15956 KB Output is correct
5 Correct 7 ms 16008 KB Output is correct
6 Correct 7 ms 15956 KB Output is correct
7 Correct 7 ms 15980 KB Output is correct
8 Correct 7 ms 15956 KB Output is correct
9 Correct 7 ms 15956 KB Output is correct
10 Correct 7 ms 15956 KB Output is correct
11 Correct 7 ms 15956 KB Output is correct
12 Correct 8 ms 16016 KB Output is correct
13 Correct 10 ms 15956 KB Output is correct
14 Correct 8 ms 15956 KB Output is correct
15 Correct 7 ms 15956 KB Output is correct
16 Correct 7 ms 15988 KB Output is correct
17 Correct 8 ms 15964 KB Output is correct
18 Correct 9 ms 15956 KB Output is correct
19 Correct 8 ms 15960 KB Output is correct
20 Correct 7 ms 15956 KB Output is correct
21 Correct 8 ms 16064 KB Output is correct
22 Correct 9 ms 15956 KB Output is correct
23 Correct 7 ms 15956 KB Output is correct
24 Correct 8 ms 15984 KB Output is correct
25 Correct 8 ms 15956 KB Output is correct
26 Correct 10 ms 15956 KB Output is correct
27 Correct 8 ms 15972 KB Output is correct
28 Correct 8 ms 15956 KB Output is correct
29 Correct 7 ms 16048 KB Output is correct
30 Correct 8 ms 15956 KB Output is correct
31 Correct 7 ms 15956 KB Output is correct
32 Correct 7 ms 15956 KB Output is correct
33 Correct 7 ms 16048 KB Output is correct
34 Correct 9 ms 15956 KB Output is correct
35 Correct 8 ms 15956 KB Output is correct
36 Correct 8 ms 15956 KB Output is correct
37 Correct 11 ms 15956 KB Output is correct
38 Correct 8 ms 15956 KB Output is correct
39 Correct 11 ms 15956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 15956 KB Output is correct
2 Correct 9 ms 15956 KB Output is correct
3 Correct 10 ms 15956 KB Output is correct
4 Correct 7 ms 15956 KB Output is correct
5 Correct 7 ms 16008 KB Output is correct
6 Correct 7 ms 15956 KB Output is correct
7 Correct 7 ms 15980 KB Output is correct
8 Correct 7 ms 15956 KB Output is correct
9 Correct 7 ms 15956 KB Output is correct
10 Correct 7 ms 15956 KB Output is correct
11 Correct 7 ms 15956 KB Output is correct
12 Correct 8 ms 16016 KB Output is correct
13 Correct 10 ms 15956 KB Output is correct
14 Correct 8 ms 15956 KB Output is correct
15 Correct 7 ms 15956 KB Output is correct
16 Correct 7 ms 15988 KB Output is correct
17 Correct 8 ms 15964 KB Output is correct
18 Correct 9 ms 15956 KB Output is correct
19 Correct 8 ms 15960 KB Output is correct
20 Correct 7 ms 15956 KB Output is correct
21 Correct 8 ms 16064 KB Output is correct
22 Correct 9 ms 15956 KB Output is correct
23 Correct 7 ms 15956 KB Output is correct
24 Correct 8 ms 15984 KB Output is correct
25 Correct 8 ms 15956 KB Output is correct
26 Correct 10 ms 15956 KB Output is correct
27 Correct 8 ms 15972 KB Output is correct
28 Correct 8 ms 15956 KB Output is correct
29 Correct 7 ms 16048 KB Output is correct
30 Correct 8 ms 15956 KB Output is correct
31 Correct 7 ms 15956 KB Output is correct
32 Correct 7 ms 15956 KB Output is correct
33 Correct 7 ms 16048 KB Output is correct
34 Correct 9 ms 15956 KB Output is correct
35 Correct 8 ms 15956 KB Output is correct
36 Correct 8 ms 15956 KB Output is correct
37 Correct 11 ms 15956 KB Output is correct
38 Correct 8 ms 15956 KB Output is correct
39 Correct 11 ms 15956 KB Output is correct
40 Correct 10 ms 15956 KB Output is correct
41 Correct 45 ms 15956 KB Output is correct
42 Correct 47 ms 16076 KB Output is correct
43 Correct 45 ms 15976 KB Output is correct
44 Correct 46 ms 15956 KB Output is correct
45 Correct 46 ms 15956 KB Output is correct
46 Correct 51 ms 16048 KB Output is correct
47 Correct 55 ms 15960 KB Output is correct
48 Correct 45 ms 15956 KB Output is correct
49 Correct 51 ms 15956 KB Output is correct
50 Correct 47 ms 16044 KB Output is correct
51 Correct 49 ms 15956 KB Output is correct
52 Correct 47 ms 16064 KB Output is correct
53 Correct 46 ms 15956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 15956 KB Output is correct
2 Correct 9 ms 15956 KB Output is correct
3 Correct 10 ms 15956 KB Output is correct
4 Correct 7 ms 15956 KB Output is correct
5 Correct 7 ms 16008 KB Output is correct
6 Correct 7 ms 15956 KB Output is correct
7 Correct 7 ms 15980 KB Output is correct
8 Correct 7 ms 15956 KB Output is correct
9 Correct 7 ms 15956 KB Output is correct
10 Correct 7 ms 15956 KB Output is correct
11 Correct 7 ms 15956 KB Output is correct
12 Correct 8 ms 16016 KB Output is correct
13 Correct 10 ms 15956 KB Output is correct
14 Correct 8 ms 15956 KB Output is correct
15 Correct 7 ms 15956 KB Output is correct
16 Correct 7 ms 15988 KB Output is correct
17 Correct 8 ms 15964 KB Output is correct
18 Correct 9 ms 15956 KB Output is correct
19 Correct 8 ms 15960 KB Output is correct
20 Correct 7 ms 15956 KB Output is correct
21 Correct 8 ms 16064 KB Output is correct
22 Correct 9 ms 15956 KB Output is correct
23 Correct 7 ms 15956 KB Output is correct
24 Correct 8 ms 15984 KB Output is correct
25 Correct 8 ms 15956 KB Output is correct
26 Correct 10 ms 15956 KB Output is correct
27 Correct 8 ms 15972 KB Output is correct
28 Correct 8 ms 15956 KB Output is correct
29 Correct 7 ms 16048 KB Output is correct
30 Correct 8 ms 15956 KB Output is correct
31 Correct 7 ms 15956 KB Output is correct
32 Correct 7 ms 15956 KB Output is correct
33 Correct 7 ms 16048 KB Output is correct
34 Correct 9 ms 15956 KB Output is correct
35 Correct 8 ms 15956 KB Output is correct
36 Correct 8 ms 15956 KB Output is correct
37 Correct 11 ms 15956 KB Output is correct
38 Correct 8 ms 15956 KB Output is correct
39 Correct 11 ms 15956 KB Output is correct
40 Correct 10 ms 15956 KB Output is correct
41 Correct 45 ms 15956 KB Output is correct
42 Correct 47 ms 16076 KB Output is correct
43 Correct 45 ms 15976 KB Output is correct
44 Correct 46 ms 15956 KB Output is correct
45 Correct 46 ms 15956 KB Output is correct
46 Correct 51 ms 16048 KB Output is correct
47 Correct 55 ms 15960 KB Output is correct
48 Correct 45 ms 15956 KB Output is correct
49 Correct 51 ms 15956 KB Output is correct
50 Correct 47 ms 16044 KB Output is correct
51 Correct 49 ms 15956 KB Output is correct
52 Correct 47 ms 16064 KB Output is correct
53 Correct 46 ms 15956 KB Output is correct
54 Correct 501 ms 16056 KB Output is correct
55 Execution timed out 3073 ms 16180 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 15956 KB Output is correct
2 Correct 9 ms 15956 KB Output is correct
3 Correct 10 ms 15956 KB Output is correct
4 Correct 7 ms 15956 KB Output is correct
5 Correct 7 ms 16008 KB Output is correct
6 Correct 7 ms 15956 KB Output is correct
7 Correct 7 ms 15980 KB Output is correct
8 Correct 7 ms 15956 KB Output is correct
9 Correct 7 ms 15956 KB Output is correct
10 Correct 7 ms 15956 KB Output is correct
11 Correct 7 ms 16036 KB Output is correct
12 Correct 7 ms 15956 KB Output is correct
13 Runtime error 22 ms 32404 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -