QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#471231 | #6698. Flipping Game | Nevll | AC ✓ | 33ms | 3880kb | C++14 | 1.4kb | 2024-07-10 19:45:50 | 2024-07-10 19:45:50 |
Judging History
answer
# include <bits/stdc++.h>
# define ll long long
# define ld double
# define fi first
# define se second
# define pii pair<int, int>
# define pll pair<ll, ll>
# pragma GCC optimize("O3")
using namespace std;
const ll MOD = 998244353;
ll C[101][101];
void build() {
for(int i=0;i<=100;i++) {
for(int k=0;k<=100;k++) {
if(i == k) C[i][k] = 1ll;
else if(i < k) C[i][k] = 0ll;
else if(k == 0) C[i][k] = 1ll;
else C[i][k] = (C[i - 1][k] + C[i - 1][k - 1]) % MOD;
}
}
}
ll dp[101][101];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
build();
int cases;
cin>>cases;
while(cases--) {
int N, K, M;
cin>>N>>K>>M;
string S, T;
cin>>S>>T;
int num = 0;
for(int c=0;c<N;c++) {
if(S[c] != T[c]) num++;
}
for(int k=0;k<=N;k++) {
dp[0][k] = 0ll;
}
dp[0][num] = 1ll;
// cout<<num<<endl;
for(int k=1;k<=K;k++) {
for(int c=0;c<=N;c++) dp[k][c] = 0ll;
for(int c=0;c<=N;c++) {
for(int d=0;d<=c && d <= M;d++) {
if((M - d) > (N - c)) continue;
if(dp[k - 1][c] == 0) continue;
ll mul = (dp[k - 1][c] * C[c][d]) % MOD;
mul *= C[N - c][M - d];
mul %= MOD;
// cout<<"mul : "<<mul<<" "<<dp[k - 1][c]<<" "<<c<<" "<<d<<" "<<C[c][d]<<endl;
dp[k][(c - d) + (M - d)] += mul;
dp[k][(c - d) + (M - d)] %= MOD;
}
}
}
printf("%lld\n", dp[K][0]);
}
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3864kb
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: 33ms
memory: 3880kb
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