QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#269579 | #3169. Editing Explosion | Terk | AC ✓ | 96ms | 14068kb | C++14 | 1017b | 2023-11-29 19:45:28 | 2023-11-29 19:45:28 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10,mod=998244353;
int n,d,m=1,ans;
string s;
int f[N],pref[N];
int Gy[22][N];//Gy下标代表压的f数组 值代表有多少符合的串T
int main(){
cin>>s>>d;
n=s.length();
s=' '+s;
for(int i=1;i<=n;i++) m*=3;
Gy[0][m-1]=1;//一开始T为空 意味着S必须全删了 f随S长度变化递增1
for(int i=0;i<=n+d;i++){//T.len
pref[0]=i;//一开始S前缀为空意味着需要把T整个删掉
f[0]=i+1;
for(int j=0;j<m;j++){//T.f的值
if(!Gy[i][j]) continue;
for(int k=1,tmp=j;k<=n;k++){//把f值拿出来
pref[k]=pref[k-1]+tmp%3-1;
tmp/=3;
}
if(pref[n]==d) ans=(ans+Gy[i][j])%mod;
for(int c=0;c<26;c++){//枚举新串用T转移
int p=0;
for(int k=1,tmp=1;k<=n;k++){
f[k]=min(pref[k]+1,min(pref[k-1]+((s[k]-'A')!=c),f[k-1]+1));
p+=tmp*(f[k]-f[k-1]+1);
tmp*=3;
}
Gy[i+1][p]=(Gy[i+1][p]+Gy[i][j])%mod;
}
}
}
cout<<ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 7692kb
input:
ICPC 1
output:
230
result:
ok single line: '230'
Test #2:
score: 0
Accepted
time: 54ms
memory: 11880kb
input:
PROGRAMMER 10
output:
110123966
result:
ok single line: '110123966'
Test #3:
score: 0
Accepted
time: 96ms
memory: 14068kb
input:
ABCDEFGHIJ 10
output:
258519532
result:
ok single line: '258519532'
Test #4:
score: 0
Accepted
time: 3ms
memory: 12292kb
input:
AAAAABBBBB 10
output:
877770338
result:
ok single line: '877770338'
Test #5:
score: 0
Accepted
time: 0ms
memory: 8124kb
input:
NOWISTHE 0
output:
1
result:
ok single line: '1'
Test #6:
score: 0
Accepted
time: 4ms
memory: 8120kb
input:
NOWISTHE 1
output:
434
result:
ok single line: '434'
Test #7:
score: 0
Accepted
time: 2ms
memory: 8964kb
input:
ABABABABAB 10
output:
555168781
result:
ok single line: '555168781'
Test #8:
score: 0
Accepted
time: 44ms
memory: 10224kb
input:
ABCDDEFGHI 3
output:
21580956
result:
ok single line: '21580956'
Test #9:
score: 0
Accepted
time: 75ms
memory: 11424kb
input:
ABCDDEFGHI 8
output:
49338700
result:
ok single line: '49338700'
Test #10:
score: 0
Accepted
time: 0ms
memory: 7740kb
input:
A 10
output:
864056661
result:
ok single line: '864056661'