Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
36255 | zqh2010 | 【S】T4 | C++ | 运行出错 | 0 | 0 MS | 260 KB | 985 | 2025-02-10 16:21:15 |
/*D jiao*/ #include<bits/stdc++.h> #define int long long using namespace std; time_t start; int k,n,m,cnt[35],dp[2][50005]; char s[50005],t[50005],s2[50005]; void gx(int l) { for(int i=0; i<=n; i++) { bool pd=1; for(int j=0; j<=m-l+1; j++) { //if(clock()-start>=5880000)return; if(i==0&&j==0)dp[i%2][j]=0; else if(i==0)dp[i%2][j]=j; else if(j==0)dp[i%2][j]=i; else { dp[i%2][j]=min(dp[i%2][j-1],dp[1-i%2][j])+1; if(s[i]==t[l+j-1])dp[i%2][j]=min(dp[i%2][j],dp[1-i%2][j-1]); else dp[i%2][j]=min(dp[i%2][j],dp[1-i%2][j-1]+1); } if(dp[i%2][j]<=k)pd=0; } if(pd)return; } for(int i=1;i<=m-l+1;i++){ if(dp[n%2][i]<=k)cnt[dp[n%2][i]]++; } } signed main() { start=clock(); ios::sync_with_stdio(false); cin.tie(0),cout.tie(0); cin>>k>>s+1>>t+1; n=strlen(s+1),m=strlen(t+1); for(int i=1;i<=m;i++){ //if(clock()-start>=588000)break; gx(i); } for(int i=0; i<=k; i++)cout<<cnt[i]<<"\n"; return 0; }