QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#261470 | #6698. Flipping Game | AH20 | WA | 33ms | 3692kb | C++14 | 1.1kb | 2023-11-22 22:05:10 | 2023-11-22 22:05:11 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod = 998244353;
ll dp[105][105];
//dp[i][j]代表执行了i次操作后还有j盏灯是亮着的方案数
char s[105],t[105],C[105][105];
//C[i][j]为预处理的组合数
void solve(){
int n,k,m,tot = 0;
cin>>n>>k>>m;
cin>>s+1;cin>>t+1;
memset(dp,0,sizeof(dp));
for(int i=1;i<=n;i++){
if(s[i]!=t[i]) ++tot;
}
dp[0][tot] = 1;
for(int i=0;i<k;i++){
for(int j=0;j<=n;j++){
if(dp[i][j] == 0) continue;
for(int h=0;h<=m and h<=j;h++){
//有h次按压到了亮着的灯上面
dp[i+1][j-h + (m-h)] = (dp[i+1][j-h + (m-h)]+
dp[i][j]*C[j][h]%mod*C[n-j][m-h]%mod
)%mod;
}
}
}
cout<<dp[k][0]<<'\n';
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int T;cin>>T;
for(int i=0;i<=100;i++){
for(int j=0;j<=i;j++){
if(j==0) C[i][j]=1;
else C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
}
}
while(T--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3608kb
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: -100
Wrong Answer
time: 33ms
memory: 3692kb
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 364849393 -251073684 0 0 0 -268823292 0 0 0 657964873 0 0 0 16152976 518284447 16636231 1 243541839 259008109 0 0 0 0 0 0 990349196 -341430689 0 0 -93815493 0 487997039 0 0 0 0 0 357611478 411739397 562040211 0 0 0 0 0 0 0 -478185468 0 51545320 703399699 0 0 0 1 0 -163928919 0 ...
result:
wrong answer 8th numbers differ - expected: '671397628', found: '364849393'