| Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|---|
| 38997 | swzzzz | 【S】T3 | C++ | 通过 | 100 | 99 MS | 9696 KB | 957 | 2025-11-27 20:01:19 |
#include<bits/stdc++.h> using namespace std; #define int long long #define mod 998244353 #define N 114 int f[N][N][N]; string s,p; int n,m; signed main(){ ios::sync_with_stdio(0); cin>>n>>m>>s>>p; s='#'+s; p='$'+p; f[0][0][0]=1; for(int i=1;i<=n;i++){ for(int l=1;l<=m;l++){ for(int r=l;r<=m;r++){ f[i][l][r]=f[i-1][l][r]*2%mod; if(l==r && s[i]==p[l]) (++f[i][l][r])%=mod; if(s[i]==p[l]) (f[i][l][r]+=f[i-1][l+1][r])%=mod; if(s[i]==p[r]) (f[i][l][r]+=f[i-1][l][r-1])%=mod; for(int k=l;k<r;k++){ (f[i][l][r]+=f[i-1][l][k]*f[i-1][k+1][r]%mod)%=mod; } for(int k=l+1;k<r;k++){ if(s[i]==p[k]) (f[i][l][r]+=f[i-1][l][k-1]*f[i-1][k+1][r])%=mod; } } } } cout<<f[n][1][m]<<endl; return 0; }