답안 #872622

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
872622 2023-11-13T13:05:17 Z winter0101 Copy and Paste 3 (JOI22_copypaste3) C++14
62 / 100
3000 ms 72844 KB
#include <bits/stdc++.h>
using namespace std;
#define all(fl) fl.begin(),fl.end()
#define pb push_back
#define fi first
#define se second
#define for1(i,j,k) for(int i=j;i<=k;i++)
#define for2(i,j,k) for(int i=j;i>=k;i--)
#define for3(i,j,k,l) for(int i=j;i<=k;i+=l)
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define pli pair<long long,int>
#define gcd __gcd
#define lcm(x,y) x*y/__gcd(x,y)
#define pil pair<int,long long>
const int maxn=2509;
int n;
string s;
long long x,y,z;
long long f[maxn][maxn];
int lcp[maxn][maxn];
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("temp.INP","r",stdin);
    //freopen("temp.OUT","w",stdout);
    cin>>n>>s>>x>>y>>z;
    s=" "+s;
    for1(i,1,n){
    for1(j,1,n){
    lcp[i][j]=lcp[i-1][j-1]-1;
    if (lcp[i-1][j-1]==0)lcp[i][j]=0;
    while (lcp[i][j]<=n-max(j,i)+1&&s[i+lcp[i][j]]==s[j+lcp[i][j]]){
    lcp[i][j]++;
    }
    }
    }
    for1(i,1,n){
    for1(j,i,n){
    f[i][j]=1ll*(j-i+1)*x;
    }
    }
    for1(len,1,n){
    for1(i,1,n-len+1){
    int j=i+len-1;
    if (i>1)f[i-1][j]=min(f[i-1][j],f[i][j]+x);
    if (j+1<=n)f[i][j+1]=min(f[i][j+1],f[i][j]+x);
    long long cost=y+z+f[i][j];
    for1(p,j+1,n){
    if (lcp[p][i]>=len){
    cost+=z;
    p+=len-1;
    }
    else {
    cost+=x;
    }
    f[i][p]=min(f[i][p],cost);
    }
    }
    }
    cout<<f[1][n];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2648 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2512 KB Output is correct
5 Correct 1 ms 2552 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2520 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 670 ms 58308 KB Output is correct
4 Correct 888 ms 62172 KB Output is correct
5 Correct 1050 ms 68340 KB Output is correct
6 Correct 1397 ms 72440 KB Output is correct
7 Correct 1740 ms 72828 KB Output is correct
8 Correct 1722 ms 72844 KB Output is correct
9 Correct 1709 ms 72832 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 6492 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2648 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2512 KB Output is correct
5 Correct 1 ms 2552 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2520 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 6492 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 6492 KB Output is correct
22 Correct 1 ms 6488 KB Output is correct
23 Correct 1 ms 6492 KB Output is correct
24 Correct 1 ms 6492 KB Output is correct
25 Correct 1 ms 6492 KB Output is correct
26 Correct 1 ms 6488 KB Output is correct
27 Correct 1 ms 6492 KB Output is correct
28 Correct 1 ms 6492 KB Output is correct
29 Correct 1 ms 6492 KB Output is correct
30 Correct 1 ms 6488 KB Output is correct
31 Correct 1 ms 6608 KB Output is correct
32 Correct 1 ms 6492 KB Output is correct
33 Correct 1 ms 6492 KB Output is correct
34 Correct 0 ms 2396 KB Output is correct
35 Correct 1 ms 2392 KB Output is correct
36 Correct 1 ms 2392 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 4444 KB Output is correct
39 Correct 1 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2648 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2512 KB Output is correct
5 Correct 1 ms 2552 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2520 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 6492 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 6492 KB Output is correct
22 Correct 1 ms 6488 KB Output is correct
23 Correct 1 ms 6492 KB Output is correct
24 Correct 1 ms 6492 KB Output is correct
25 Correct 1 ms 6492 KB Output is correct
26 Correct 1 ms 6488 KB Output is correct
27 Correct 1 ms 6492 KB Output is correct
28 Correct 1 ms 6492 KB Output is correct
29 Correct 1 ms 6492 KB Output is correct
30 Correct 1 ms 6488 KB Output is correct
31 Correct 1 ms 6608 KB Output is correct
32 Correct 1 ms 6492 KB Output is correct
33 Correct 1 ms 6492 KB Output is correct
34 Correct 0 ms 2396 KB Output is correct
35 Correct 1 ms 2392 KB Output is correct
36 Correct 1 ms 2392 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 4444 KB Output is correct
39 Correct 1 ms 6492 KB Output is correct
40 Correct 1 ms 6492 KB Output is correct
41 Correct 2 ms 8540 KB Output is correct
42 Correct 3 ms 8756 KB Output is correct
43 Correct 5 ms 8744 KB Output is correct
44 Correct 4 ms 8540 KB Output is correct
45 Correct 3 ms 8540 KB Output is correct
46 Correct 3 ms 8540 KB Output is correct
47 Correct 3 ms 8540 KB Output is correct
48 Correct 3 ms 8736 KB Output is correct
49 Correct 3 ms 8540 KB Output is correct
50 Correct 3 ms 8752 KB Output is correct
51 Correct 3 ms 8536 KB Output is correct
52 Correct 3 ms 8656 KB Output is correct
53 Correct 3 ms 8792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2648 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2512 KB Output is correct
5 Correct 1 ms 2552 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2520 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 6492 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 6492 KB Output is correct
22 Correct 1 ms 6488 KB Output is correct
23 Correct 1 ms 6492 KB Output is correct
24 Correct 1 ms 6492 KB Output is correct
25 Correct 1 ms 6492 KB Output is correct
26 Correct 1 ms 6488 KB Output is correct
27 Correct 1 ms 6492 KB Output is correct
28 Correct 1 ms 6492 KB Output is correct
29 Correct 1 ms 6492 KB Output is correct
30 Correct 1 ms 6488 KB Output is correct
31 Correct 1 ms 6608 KB Output is correct
32 Correct 1 ms 6492 KB Output is correct
33 Correct 1 ms 6492 KB Output is correct
34 Correct 0 ms 2396 KB Output is correct
35 Correct 1 ms 2392 KB Output is correct
36 Correct 1 ms 2392 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 4444 KB Output is correct
39 Correct 1 ms 6492 KB Output is correct
40 Correct 1 ms 6492 KB Output is correct
41 Correct 2 ms 8540 KB Output is correct
42 Correct 3 ms 8756 KB Output is correct
43 Correct 5 ms 8744 KB Output is correct
44 Correct 4 ms 8540 KB Output is correct
45 Correct 3 ms 8540 KB Output is correct
46 Correct 3 ms 8540 KB Output is correct
47 Correct 3 ms 8540 KB Output is correct
48 Correct 3 ms 8736 KB Output is correct
49 Correct 3 ms 8540 KB Output is correct
50 Correct 3 ms 8752 KB Output is correct
51 Correct 3 ms 8536 KB Output is correct
52 Correct 3 ms 8656 KB Output is correct
53 Correct 3 ms 8792 KB Output is correct
54 Correct 24 ms 19032 KB Output is correct
55 Correct 99 ms 33620 KB Output is correct
56 Correct 276 ms 33412 KB Output is correct
57 Correct 247 ms 33408 KB Output is correct
58 Correct 260 ms 33416 KB Output is correct
59 Correct 237 ms 33416 KB Output is correct
60 Correct 287 ms 33368 KB Output is correct
61 Correct 181 ms 33368 KB Output is correct
62 Correct 106 ms 33384 KB Output is correct
63 Correct 209 ms 33372 KB Output is correct
64 Correct 225 ms 33412 KB Output is correct
65 Correct 164 ms 33368 KB Output is correct
66 Correct 170 ms 33368 KB Output is correct
67 Correct 245 ms 33412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2648 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2512 KB Output is correct
5 Correct 1 ms 2552 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2520 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 670 ms 58308 KB Output is correct
14 Correct 888 ms 62172 KB Output is correct
15 Correct 1050 ms 68340 KB Output is correct
16 Correct 1397 ms 72440 KB Output is correct
17 Correct 1740 ms 72828 KB Output is correct
18 Correct 1722 ms 72844 KB Output is correct
19 Correct 1709 ms 72832 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 1 ms 6492 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 4444 KB Output is correct
29 Correct 1 ms 4444 KB Output is correct
30 Correct 1 ms 6492 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 6492 KB Output is correct
33 Correct 1 ms 4444 KB Output is correct
34 Correct 0 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 4444 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 6492 KB Output is correct
39 Correct 1 ms 6488 KB Output is correct
40 Correct 1 ms 6492 KB Output is correct
41 Correct 1 ms 6492 KB Output is correct
42 Correct 1 ms 6492 KB Output is correct
43 Correct 1 ms 6488 KB Output is correct
44 Correct 1 ms 6492 KB Output is correct
45 Correct 1 ms 6492 KB Output is correct
46 Correct 1 ms 6492 KB Output is correct
47 Correct 1 ms 6488 KB Output is correct
48 Correct 1 ms 6608 KB Output is correct
49 Correct 1 ms 6492 KB Output is correct
50 Correct 1 ms 6492 KB Output is correct
51 Correct 0 ms 2396 KB Output is correct
52 Correct 1 ms 2392 KB Output is correct
53 Correct 1 ms 2392 KB Output is correct
54 Correct 1 ms 2396 KB Output is correct
55 Correct 1 ms 4444 KB Output is correct
56 Correct 1 ms 6492 KB Output is correct
57 Correct 1 ms 6492 KB Output is correct
58 Correct 2 ms 8540 KB Output is correct
59 Correct 3 ms 8756 KB Output is correct
60 Correct 5 ms 8744 KB Output is correct
61 Correct 4 ms 8540 KB Output is correct
62 Correct 3 ms 8540 KB Output is correct
63 Correct 3 ms 8540 KB Output is correct
64 Correct 3 ms 8540 KB Output is correct
65 Correct 3 ms 8736 KB Output is correct
66 Correct 3 ms 8540 KB Output is correct
67 Correct 3 ms 8752 KB Output is correct
68 Correct 3 ms 8536 KB Output is correct
69 Correct 3 ms 8656 KB Output is correct
70 Correct 3 ms 8792 KB Output is correct
71 Correct 24 ms 19032 KB Output is correct
72 Correct 99 ms 33620 KB Output is correct
73 Correct 276 ms 33412 KB Output is correct
74 Correct 247 ms 33408 KB Output is correct
75 Correct 260 ms 33416 KB Output is correct
76 Correct 237 ms 33416 KB Output is correct
77 Correct 287 ms 33368 KB Output is correct
78 Correct 181 ms 33368 KB Output is correct
79 Correct 106 ms 33384 KB Output is correct
80 Correct 209 ms 33372 KB Output is correct
81 Correct 225 ms 33412 KB Output is correct
82 Correct 164 ms 33368 KB Output is correct
83 Correct 170 ms 33368 KB Output is correct
84 Correct 245 ms 33412 KB Output is correct
85 Correct 1311 ms 51920 KB Output is correct
86 Execution timed out 3044 ms 72580 KB Time limit exceeded
87 Halted 0 ms 0 KB -