QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#592180 | #6698. Flipping Game | Foedere0 | AC ✓ | 180ms | 3716kb | C++20 | 1.3kb | 2024-09-26 21:03:22 | 2024-09-26 21:03:28 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
typedef pair<int, int> PII;
int n, m, k;
string s1, s2;
int mod = 998244353;
int c[110][110];
int dp[110][110];
void into()
{
for (int i = 0; i <= 105; i++)
{
c[i][0] = 1;
for (int j = 1; j <= i; j++)
{
c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
}
}
}
void solve()
{
memset(dp, 0, sizeof(dp));
int cnt = 0;
cin >> n >> k >> m;
cin >> s1 >> s2;
s1 = ' ' + s1;
s2 = ' ' + s2;
for (int i = 1; i <= n; i++)
{
if (s1[i] != s2[i])
{
cnt++;
}
}
dp[0][cnt] = 1;
for (int i = 0; i < k; i++)
{
for (int j = 0; j <= n; j++)
{
for (int k = 0; k <= m; k++)
{
if (j + 2 * k - m >= 0 && j + 2 * k - m <= n)
{
dp[i + 1][j + 2 * k - m] += (dp[i][j] * (c[n - j][k] * c[j][m - k] % mod)) % mod;
dp[i + 1][j + 2 * k - m] %= mod;
}
}
}
}
cout << dp[k][0] << endl;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
into();
int T = 1;
cin >> T;
while (T--)
{
solve();
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3716kb
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: 180ms
memory: 3660kb
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