Submission #1004302

# Submission time Handle Problem Language Result Execution time Memory
1004302 2024-06-21T07:28:59 Z De3b0o Copy and Paste 3 (JOI22_copypaste3) C++14
25 / 100
415 ms 50480 KB
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid ((l+r)/2)
#define lc (2*x)
#define rc (2*x+1)

using namespace std;

ll n;
string s;
ll A , B , C;
bitset<1600000090> e;
ll dp[209][209];
vector<ll> idx[209][209];

ll gt(ll i , ll j , ll l1 , ll r1)
{
    ll l = 0 , r = idx[i][j].size()-1;
    ll sum = 0;
    while(l<=r)
    {
        if(idx[i][j][mid]>r1)
            r=mid-1;
        else
        {
            sum=mid+1;
            l=mid+1;
        }
    }
    sum*=(j-i+1);
    return sum;
}

ll solve(ll l , ll r)
{
    if(dp[l][r])
        return dp[l][r];
    ll ans = (r-l+1)*A;
    for(ll i = l ; r>i ; i++)
    {
        for(ll j = i ; r>j ; j++)
        {
            ll ans1 = solve(i,j) + B + (i-l)*A + C;
            ll y = gt(i,j,j+1,r);
            ans1+=y/(j-i+1)*C;
            ans1+=(r-j-y)*A;
            ans=min(ans,ans1);
        }
    }
    dp[l][r]=ans;
    return ans;
}

int main()
{
    cin >> n;
    cin >> s;
    cin >> A >> B >> C;
    for(ll i = 0 ; n>i ; i++)
    {
        for(ll j = i ; n>j ; j++)
        {
            for(ll i1 = j+1 ; n>i1 ; i1++)
            {
                ll j1 = i1+(j-i);
                if(j1>=n)
                    break;
                e[i+j*n+i1*n*n+j1*n*n*n]=1;
                for(ll h = i ; j>=h ; h++)
                {
                    if(s[h]!=s[i1+(h-i)])
                        e[i+j*n+i1*n*n+j1*n*n*n]=0;
                }
            }
            for(int h = j+1 ; n>h ; h++)
            {
                ll i1 = h , j1 = h+j-i;
                if(j1>=n)
                    break;
                if(e[i+j*n+i1*n*n+j1*n*n*n])
                {
                    idx[i][j].pb(j1);
                    h=j1;
                }
            }
        }
    }
    ll ans = solve(0,n-1);
    cans
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1372 KB Output is correct
2 Correct 1 ms 1372 KB Output is correct
3 Correct 1 ms 1372 KB Output is correct
4 Correct 1 ms 1372 KB Output is correct
5 Correct 1 ms 1372 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 1 ms 1372 KB Output is correct
8 Correct 1 ms 1476 KB Output is correct
9 Correct 1 ms 1372 KB Output is correct
10 Correct 1 ms 1484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1440 KB Output is correct
2 Correct 1 ms 1372 KB Output is correct
3 Runtime error 4 ms 2652 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1372 KB Output is correct
2 Correct 1 ms 1372 KB Output is correct
3 Correct 1 ms 1372 KB Output is correct
4 Correct 1 ms 1372 KB Output is correct
5 Correct 1 ms 1372 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 1 ms 1372 KB Output is correct
8 Correct 1 ms 1476 KB Output is correct
9 Correct 1 ms 1372 KB Output is correct
10 Correct 1 ms 1484 KB Output is correct
11 Correct 1 ms 1372 KB Output is correct
12 Correct 1 ms 1372 KB Output is correct
13 Correct 1 ms 1372 KB Output is correct
14 Correct 1 ms 1372 KB Output is correct
15 Correct 1 ms 1372 KB Output is correct
16 Correct 1 ms 1372 KB Output is correct
17 Correct 0 ms 1372 KB Output is correct
18 Correct 1 ms 1372 KB Output is correct
19 Correct 1 ms 1372 KB Output is correct
20 Correct 1 ms 1372 KB Output is correct
21 Correct 1 ms 1628 KB Output is correct
22 Correct 1 ms 1372 KB Output is correct
23 Correct 1 ms 1628 KB Output is correct
24 Correct 2 ms 1628 KB Output is correct
25 Correct 1 ms 1472 KB Output is correct
26 Correct 1 ms 1372 KB Output is correct
27 Correct 1 ms 1628 KB Output is correct
28 Correct 1 ms 1628 KB Output is correct
29 Correct 1 ms 1628 KB Output is correct
30 Correct 1 ms 1628 KB Output is correct
31 Correct 1 ms 1372 KB Output is correct
32 Correct 1 ms 1628 KB Output is correct
33 Correct 1 ms 1372 KB Output is correct
34 Correct 1 ms 1372 KB Output is correct
35 Correct 1 ms 1372 KB Output is correct
36 Correct 1 ms 1372 KB Output is correct
37 Correct 1 ms 1372 KB Output is correct
38 Correct 1 ms 1368 KB Output is correct
39 Correct 1 ms 1624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1372 KB Output is correct
2 Correct 1 ms 1372 KB Output is correct
3 Correct 1 ms 1372 KB Output is correct
4 Correct 1 ms 1372 KB Output is correct
5 Correct 1 ms 1372 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 1 ms 1372 KB Output is correct
8 Correct 1 ms 1476 KB Output is correct
9 Correct 1 ms 1372 KB Output is correct
10 Correct 1 ms 1484 KB Output is correct
11 Correct 1 ms 1372 KB Output is correct
12 Correct 1 ms 1372 KB Output is correct
13 Correct 1 ms 1372 KB Output is correct
14 Correct 1 ms 1372 KB Output is correct
15 Correct 1 ms 1372 KB Output is correct
16 Correct 1 ms 1372 KB Output is correct
17 Correct 0 ms 1372 KB Output is correct
18 Correct 1 ms 1372 KB Output is correct
19 Correct 1 ms 1372 KB Output is correct
20 Correct 1 ms 1372 KB Output is correct
21 Correct 1 ms 1628 KB Output is correct
22 Correct 1 ms 1372 KB Output is correct
23 Correct 1 ms 1628 KB Output is correct
24 Correct 2 ms 1628 KB Output is correct
25 Correct 1 ms 1472 KB Output is correct
26 Correct 1 ms 1372 KB Output is correct
27 Correct 1 ms 1628 KB Output is correct
28 Correct 1 ms 1628 KB Output is correct
29 Correct 1 ms 1628 KB Output is correct
30 Correct 1 ms 1628 KB Output is correct
31 Correct 1 ms 1372 KB Output is correct
32 Correct 1 ms 1628 KB Output is correct
33 Correct 1 ms 1372 KB Output is correct
34 Correct 1 ms 1372 KB Output is correct
35 Correct 1 ms 1372 KB Output is correct
36 Correct 1 ms 1372 KB Output is correct
37 Correct 1 ms 1372 KB Output is correct
38 Correct 1 ms 1368 KB Output is correct
39 Correct 1 ms 1624 KB Output is correct
40 Correct 17 ms 3416 KB Output is correct
41 Correct 415 ms 50480 KB Output is correct
42 Correct 335 ms 49748 KB Output is correct
43 Correct 322 ms 49564 KB Output is correct
44 Correct 338 ms 49676 KB Output is correct
45 Correct 312 ms 49440 KB Output is correct
46 Correct 313 ms 49556 KB Output is correct
47 Correct 357 ms 49744 KB Output is correct
48 Correct 365 ms 49832 KB Output is correct
49 Correct 303 ms 49744 KB Output is correct
50 Correct 314 ms 49576 KB Output is correct
51 Correct 349 ms 49952 KB Output is correct
52 Correct 349 ms 49876 KB Output is correct
53 Correct 287 ms 49404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1372 KB Output is correct
2 Correct 1 ms 1372 KB Output is correct
3 Correct 1 ms 1372 KB Output is correct
4 Correct 1 ms 1372 KB Output is correct
5 Correct 1 ms 1372 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 1 ms 1372 KB Output is correct
8 Correct 1 ms 1476 KB Output is correct
9 Correct 1 ms 1372 KB Output is correct
10 Correct 1 ms 1484 KB Output is correct
11 Correct 1 ms 1372 KB Output is correct
12 Correct 1 ms 1372 KB Output is correct
13 Correct 1 ms 1372 KB Output is correct
14 Correct 1 ms 1372 KB Output is correct
15 Correct 1 ms 1372 KB Output is correct
16 Correct 1 ms 1372 KB Output is correct
17 Correct 0 ms 1372 KB Output is correct
18 Correct 1 ms 1372 KB Output is correct
19 Correct 1 ms 1372 KB Output is correct
20 Correct 1 ms 1372 KB Output is correct
21 Correct 1 ms 1628 KB Output is correct
22 Correct 1 ms 1372 KB Output is correct
23 Correct 1 ms 1628 KB Output is correct
24 Correct 2 ms 1628 KB Output is correct
25 Correct 1 ms 1472 KB Output is correct
26 Correct 1 ms 1372 KB Output is correct
27 Correct 1 ms 1628 KB Output is correct
28 Correct 1 ms 1628 KB Output is correct
29 Correct 1 ms 1628 KB Output is correct
30 Correct 1 ms 1628 KB Output is correct
31 Correct 1 ms 1372 KB Output is correct
32 Correct 1 ms 1628 KB Output is correct
33 Correct 1 ms 1372 KB Output is correct
34 Correct 1 ms 1372 KB Output is correct
35 Correct 1 ms 1372 KB Output is correct
36 Correct 1 ms 1372 KB Output is correct
37 Correct 1 ms 1372 KB Output is correct
38 Correct 1 ms 1368 KB Output is correct
39 Correct 1 ms 1624 KB Output is correct
40 Correct 17 ms 3416 KB Output is correct
41 Correct 415 ms 50480 KB Output is correct
42 Correct 335 ms 49748 KB Output is correct
43 Correct 322 ms 49564 KB Output is correct
44 Correct 338 ms 49676 KB Output is correct
45 Correct 312 ms 49440 KB Output is correct
46 Correct 313 ms 49556 KB Output is correct
47 Correct 357 ms 49744 KB Output is correct
48 Correct 365 ms 49832 KB Output is correct
49 Correct 303 ms 49744 KB Output is correct
50 Correct 314 ms 49576 KB Output is correct
51 Correct 349 ms 49952 KB Output is correct
52 Correct 349 ms 49876 KB Output is correct
53 Correct 287 ms 49404 KB Output is correct
54 Runtime error 4 ms 2648 KB Execution killed with signal 11
55 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1372 KB Output is correct
2 Correct 1 ms 1372 KB Output is correct
3 Correct 1 ms 1372 KB Output is correct
4 Correct 1 ms 1372 KB Output is correct
5 Correct 1 ms 1372 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 1 ms 1372 KB Output is correct
8 Correct 1 ms 1476 KB Output is correct
9 Correct 1 ms 1372 KB Output is correct
10 Correct 1 ms 1484 KB Output is correct
11 Correct 1 ms 1440 KB Output is correct
12 Correct 1 ms 1372 KB Output is correct
13 Runtime error 4 ms 2652 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -