QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#226883#3169. Editing ExplosionSolitaryDream#AC ✓340ms13300kbC++171.0kb2023-10-26 17:42:142023-10-26 17:42:14

Judging History

你现在查看的是最新测评结果

  • [2023-10-26 17:42:14]
  • 评测
  • 测评结果:AC
  • 用时:340ms
  • 内存:13300kb
  • [2023-10-26 17:42:14]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

const int N=111,P=998244353;

map<vector<int>,int>f[31];

int n,d;

char s[N];

int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    scanf("%d",&d);
    vector<int> beg(n+1);
    for(int i=1;i<=n;i++)
        beg[i]=i;
    f[0][beg]++;
    for(int i=0;i<n+d;i++)
    {
        for(auto [dp,w]:f[i])
        {
            for(int j=0;j<26;j++)
            {
                vector<int> ndp(n+1);
                for(int x=0;x<=n;x++)
                {
                    ndp[x]=d+1;
                    ndp[x]=min(ndp[x],dp[x]+1);
                    if(x)
                        ndp[x]=min(ndp[x],ndp[x-1]+1);
                    if(x)
                        ndp[x]=min(ndp[x],dp[x-1]+(s[x]-'A'!=j));
                }
                f[i+1][ndp]=(f[i+1][ndp]+w)%P;
            }
        }
    }
    int ans=0;
    for(int i=0;i<=n+d;i++)
        for(auto [dp,w]:f[i])
            if(dp[n]==d)
                ans=(ans+w)%P;
    printf("%d\n",ans);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3800kb

input:

ICPC 1

output:

230

result:

ok single line: '230'

Test #2:

score: 0
Accepted
time: 196ms
memory: 9504kb

input:

PROGRAMMER 10

output:

110123966

result:

ok single line: '110123966'

Test #3:

score: 0
Accepted
time: 340ms
memory: 13300kb

input:

ABCDEFGHIJ 10

output:

258519532

result:

ok single line: '258519532'

Test #4:

score: 0
Accepted
time: 12ms
memory: 4472kb

input:

AAAAABBBBB 10

output:

877770338

result:

ok single line: '877770338'

Test #5:

score: 0
Accepted
time: 0ms
memory: 4076kb

input:

NOWISTHE 0

output:

1

result:

ok single line: '1'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

NOWISTHE 1

output:

434

result:

ok single line: '434'

Test #7:

score: 0
Accepted
time: 5ms
memory: 4000kb

input:

ABABABABAB 10

output:

555168781

result:

ok single line: '555168781'

Test #8:

score: 0
Accepted
time: 3ms
memory: 3888kb

input:

ABCDDEFGHI 3

output:

21580956

result:

ok single line: '21580956'

Test #9:

score: 0
Accepted
time: 185ms
memory: 8976kb

input:

ABCDDEFGHI 8

output:

49338700

result:

ok single line: '49338700'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

A 10

output:

864056661

result:

ok single line: '864056661'