QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#408074#6698. Flipping Gamecur_nxtWA 45ms3920kbC++201.3kb2024-05-09 17:40:012024-05-09 17:40:02

Judging History

你现在查看的是最新测评结果

  • [2024-05-09 17:40:02]
  • 评测
  • 测评结果:WA
  • 用时:45ms
  • 内存:3920kb
  • [2024-05-09 17:40:01]
  • 提交

answer

#include <bits/stdc++.h>
#define ioclear std::ios::sync_with_stdio(false);std::cin.tie(nullptr);std::cout.tie(nullptr);
#define endl '\n'
#define int long long 

using namespace std;

constexpr int mmax = 110;
constexpr int mod = 998'244'353;

int C[mmax][mmax];
int dp[mmax][mmax];

void init(int _n)
{
	for(int i = 0; i < _n; 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()
{
	int n, k, m;
	std::cin >> n >> k >> m;
	std::string s, t;
	std::cin >> s >> t;
	int cnt = 0;
	for(int i = 0; i < n; i++)
		cnt += (s[i] != t[i]);
	for(int i = 0; i <= k; i++)
		for(int j = 0; j <= n; j++)
			dp[i][j] = 0;
	dp[0][cnt] = 1;
	
	auto add = [](auto &x, auto y)
	{
	    x = (x + y) % mod;
	};
	
	for(int i = 0; i < k; i++)
		for(int j = 0; j <= n; j++)
		{
//			int cur = n - j;
			for(int t = 0; t <= j && t <= m; t++)
			{
				// j + m - 2t >= 0
				if(m - t > n - j)
				    continue;
				add(dp[i + 1][j - t + (m - t)], (dp[i][j] % mod) * (C[j][t] % mod) * (C[n - j][m - t] % mod));
			}
		}
	std::cout << dp[k][0] % mod << endl;
}

signed main()
{
	#ifdef ONLINE_JUDGE
	ioclear;
	#endif
	init(105);
	int t;
	std::cin >> t;
	while(t--)
		solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3848kb

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: 45ms
memory: 3920kb

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:

wrong answer 901st numbers differ - expected: '295081541', found: '-924849851'