QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#236322#6698. Flipping GamestcmuyiAC ✓45ms11140kbC++201.2kb2023-11-03 20:40:332023-11-03 20:40:34

Judging History

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

  • [2023-11-03 20:40:34]
  • 评测
  • 测评结果:AC
  • 用时:45ms
  • 内存:11140kb
  • [2023-11-03 20:40:33]
  • 提交

answer

#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define i64 long long
#define endl '\n'
#define lb(x) ((x) & (-x))
using namespace std;
const i64 mod = 998244353;
const int maxn = 1e3+10;
i64 c[1005][1005];
signed main()
{
    IOS;
    for (int i = 0; i <= 1000; ++i)
    {
        for (int j = 0; j <= i; ++j)
        {
            if (!j) c[i][j] = 1;
            else c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
        }
    }
    int t;
    cin >> t;
    while(t--)
    {
        int n,k,m;
        cin >> n >> k >> m;
        string a,b;
        cin >> a >> b;
        int cnt = 0;
        for(int i = 0; i < n; ++i) if(a[i] != b[i]) cnt++;
        vector<vector<i64>> dp(k+1,vector<i64> (n+1));
        dp[0][cnt] = 1;
        for(int i = 1; i <= k; ++i)
        {
            for(int j = 0; j <= n; ++j)
            {
                for(int l = 0; l <= j && l <= m; ++l)
                {
                    if(n-j >= m-l) dp[i][j - l + m - l] = (dp[i][j - l + m - l] + dp[i-1][j] * c[j][l] % mod * c[n-j][m-l] % mod) % mod;
                }
            }
        }
        cout << dp[k][0] << endl;
    }
    return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 10724kb

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

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