QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#234766#6698. Flipping GameEndPBWA 135ms6288kbC++172.4kb2023-11-01 22:01:182023-11-01 22:01:18

Judging History

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

  • [2023-11-01 22:01:18]
  • 评测
  • 测评结果:WA
  • 用时:135ms
  • 内存:6288kb
  • [2023-11-01 22:01:18]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
//cout << fixed <<setprecision(2) << ans;
//inline ll read() {
//	ll ans=0,f=1;
//	char c=getchar();
//	while(c<'0' || c>'9') {
//		if(c=='-') f=-1;
//		c=getchar();
//	}
//	while(c>='0' && c<='9') {
//		ans=(ans<<1)+(ans<<3)+(c^48);
//		c=getchar();
//	}
//	return ans*f;
//}
//char F[200];
//inline void out(I_int x) {
//    if (x == 0) return (void) (putchar('0'));
//    I_int tmp = x > 0 ? x : -x;
//    if (x < 0) putchar('-');
//    int cnt = 0;
//    while (tmp > 0) {
//        F[cnt++] = tmp % 10 + '0';
//        tmp /= 10;
//    }
//    while (cnt > 0) putchar(F[--cnt]);
//    //cout<<" ";
//}
#define endl '\n'
const ll N = 1e5 + 5, mod = 998244353;
ll n, m;
string s, st;
ll dp[205][205];
ll fac[2 * N], invfac[2 * N];

ll quick_pow(ll a, ll b) {
    if (a == 0)return 0;
    ll ans = 1;
    while (b) {
        if (b & 1)ans = ans * a % mod;
        a = a * a % mod;
        b = b >> 1;
    }
    return ans;
}

ll inv(ll x) {
    return quick_pow(x, mod - 2);
}

void init() {
    fac[0] = invfac[0] = 1;
    for (int i = 1; i < N; i++) {
        fac[i] = fac[i - 1] * i % mod;
    }
    invfac[N - 1] = inv(fac[N - 1]);
    for (int i = N - 2; i >= 1; i--) {
        invfac[i] = invfac[i + 1] * (i + 1) % mod;
    }
}

ll C(ll a, ll b) {
    if (b < a)return 0;
    return fac[b] * invfac[b - a] % mod * invfac[a] % mod;
}

void solve() {
    ll k;
    cin >> n >> m >> k;
    cin >> s;
    cin >> st;
    ll cnt = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] != st[i])cnt++;
    }
    for (int i = 0; i <= m; i++) {
        for (int j = 0; j <= n; j++) {
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;
    for (int i = 1; i <= m; i++) {
        for (int j = 0; j <= n; j++) {
            for (int u = 0; u <= j; u++) {
                if (k - u > n - j)continue;
                if (j + k - 2 * u < 0 || j + k - 2 * u > n)continue;
                dp[i][j + k - 2 * u] += dp[i - 1][j] * C(u, j) % mod * C(k - u, n - j) % mod;
                dp[i][j + k - 2 * u] %= mod;
            }
        }
    }
    cout << dp[m][cnt] * inv(C(cnt, n) % mod) % mod << endl;
    return;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    init();
    cin >> _;
    while (_--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 5972kb

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: 135ms
memory: 6288kb

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
885150283
0
507894927
379728875
0
0
0
797462433
0
0
0
657964873
0
0
0
430166099
974972630
16636231
1
498114734
259008109
0
0
0
0
0
0
990349196
800783630
0
0
662532876
0
905809796
0
0
0
0
0
317383222
411739397
988252358
0
0
0
0
0
0
0
-924486245
0
77531359
254864862
0
0
0
1
0
710633791
0
0
0...

result:

wrong answer 6th numbers differ - expected: '565123576', found: '885150283'