답안 #1060915

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1060915 2024-08-16T04:30:47 Z 12345678 Copy and Paste 3 (JOI22_copypaste3) C++17
1 / 100
2 ms 4444 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const ll nx=505, mod=1e9+7, mul=31;

ll n, a, b, c, s[nx], dp[nx][nx];
string stmp;

bool match(int l1, int r1, int l2, int r2)
{
    for (int i=0; i<=r1-l1; i++) if (s[l1+i]!=s[l2+i]) return 0;
    return 1;
}

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>stmp>>a>>b>>c;
    for (int i=1; i<=n; i++) s[i]=stmp[i-1]-'a'+1;
    for (int i=1; i<=n; i++) dp[i][i]=a;
    for (int sz=1; sz<=n; sz++)
    {
        for (int l=1; l+sz<=n; l++)
        {
            int r=l+sz;
            dp[l][r]=min(dp[l+1][r], dp[l][r-1])+a;
            for (int md=l; md<=r; md++)
            {
                ll idx=md+1, cnt=1, blk=0;
                while (idx<=r)
                {
                    if (idx+md-1<=r&&match(l, md, idx, idx+md-l)) cnt++, idx=idx+md-l+1;
                    else idx++, blk++;
                }
                dp[l][r]=min(dp[l][r], dp[l][md]+blk*a+c*cnt+b);
            }
        }
    }
    cout<<dp[1][n];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 2 ms 4444 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Incorrect 1 ms 348 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Incorrect 1 ms 348 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Incorrect 1 ms 348 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Runtime error 2 ms 4444 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -