QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#612828 | #6698. Flipping Game | zqx# | AC ✓ | 56ms | 4020kb | C++23 | 1.1kb | 2024-10-05 13:08:19 | 2024-10-05 13:08:20 |
Judging History
answer
#include<bits/stdc++.h>
#define AC return 0;
#define int long long
#define pii pair<int,int>
#define all(tar) tar.begian(),tar.end()
const int maxx=2e5+5;
const int mod=998244353;
using namespace std;
int n,m,k,t;
int c[105][105];
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
c[0][0]=1;
for(int i=1;i<=100;i++){
c[i][0]=c[i][i]=1;
for(int j=1;j<i;j++)c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
}
cin>>t;
while(t--){
cin>>n>>k>>m;
vector<vector<int>>dp(k+1,vector<int>(n+1,0));
int cnt=0;
string a,b;
cin>>a>>b;
for(int i=0;i<n;i++){
if(a[i]==b[i])cnt++;
}
dp[0][cnt]=1;
for(int i=1;i<=k;i++){
for(int j=0;j<=n;j++){
for(int p=0;p<=min(j,m);p++){
//p个0->1 m-p个 1->0
if(m-p>n-j)continue;
if(j-p+m-p>=0)(dp[i][j-p+m-p]+=dp[i-1][j]*c[j][p]%mod
*c[n-j][m-p]%mod)%=mod;
}
}
// for(int j=0;j<=n;j++)cout<<i<<" "<<j<<" "<<dp[i][j]<<'\n';
}
cout<<dp[k][n]<<'\n';
}
AC
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3612kb
input:
3 3 2 1 001 100 3 1 2 001 100 3 3 2 001 100
output:
2 1 7
result:
ok 3 number(s): "2 1 7"
Test #2:
score: 0
Accepted
time: 56ms
memory: 4020kb
input:
1000 8 50 2 11111001 01100001 13 4 5 0010011001101 0000001010010 15 58 12 011111110110100 011010000101000 15 30 2 000101100111101 100010100110000 16 99 15 0111011010111101 1000100101011100 7 73 1 0010010 1010111 1 45 1 1 1 15 64 4 111000001000100 111000110011011 13 16 6 0000001101000 0101001010111 5...
output:
0 0 0 0 0 565123576 0 671397628 866048220 0 0 0 934159397 0 0 0 657964873 0 0 0 297620792 518284447 16636231 1 294524820 259008109 0 0 0 0 0 0 990349196 899244686 0 0 497963164 0 49814547 0 0 0 0 0 529815127 411739397 562040211 0 0 0 0 0 0 0 531433326 0 77531359 703399699 0 0 0 1 0 896329183 0 0 0 0...
result:
ok 1000 numbers