結果

問題 No.1655 123 Swaps
ユーザー 👑 hitonanodehitonanode
提出日時 2021-09-14 23:33:12
言語 C++23(draft)
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,763 bytes
コンパイル時間 2,522 ms
コンパイル使用メモリ 144,808 KB
実行使用メモリ 14,000 KB
最終ジャッジ日時 2023-09-09 22:44:49
合計ジャッジ時間 8,209 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
5,224 KB
testcase_01 AC 6 ms
5,340 KB
testcase_02 AC 6 ms
5,276 KB
testcase_03 AC 6 ms
5,268 KB
testcase_04 AC 6 ms
5,252 KB
testcase_05 AC 6 ms
5,364 KB
testcase_06 AC 6 ms
5,380 KB
testcase_07 AC 6 ms
5,480 KB
testcase_08 AC 6 ms
5,320 KB
testcase_09 AC 6 ms
5,436 KB
testcase_10 AC 6 ms
5,316 KB
testcase_11 AC 6 ms
5,300 KB
testcase_12 AC 6 ms
5,324 KB
testcase_13 AC 5 ms
5,152 KB
testcase_14 AC 6 ms
5,156 KB
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 67 ms
10,292 KB
testcase_27 RE -
testcase_28 AC 68 ms
10,776 KB
testcase_29 AC 67 ms
10,428 KB
testcase_30 RE -
testcase_31 RE -
testcase_32 AC 6 ms
5,432 KB
testcase_33 AC 6 ms
5,380 KB
testcase_34 AC 6 ms
5,320 KB
testcase_35 AC 11 ms
6,952 KB
testcase_36 AC 10 ms
7,056 KB
testcase_37 AC 8 ms
6,560 KB
testcase_38 RE -
testcase_39 AC 17 ms
8,596 KB
testcase_40 AC 15 ms
8,380 KB
testcase_41 AC 6 ms
5,372 KB
testcase_42 AC 6 ms
5,312 KB
testcase_43 AC 7 ms
5,472 KB
testcase_44 AC 6 ms
5,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

#include <atcoder/modint>
#include <atcoder/convolution>
using mint = atcoder::static_modint<924844033>;

template <typename modint> struct acl_fac {
    std::vector<modint> facs, facinvs;
    acl_fac(int N) {
        assert(-1 <= N and N < modint::mod());
        facs.resize(N + 1, 1);
        for (int i = 1; i <= N; i++) facs[i] = facs[i - 1] * i;
        facinvs.assign(N + 1, facs.back().inv());
        for (int i = N; i > 0; i--) facinvs[i - 1] = facinvs[i] * i;
    }
    modint ncr(int n, int r) const {
        if (n < 0 or r < 0 or n < r) return 0;
        return facs[n] * facinvs[r] * facinvs[n - r];
    }
    modint operator[](int i) const { return facs[i]; }
    modint finv(int i) const { return facinvs[i]; }
};
acl_fac<mint> fac(300000);


int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if ((A + B + C) % 2) {
        puts("0");
        return 0;
    }

    const int N = (A + B + C) / 2;
    vector<mint> dpsum(N + 1);
    auto gen = [&N](int B, int bsum) {
        vector<mint> f(N + 1);
        for (int b = 0; b <= min(N, B); b++) {
            int bs = b - (B - b);
            if ((bs % 3 + 3) % 3 != bsum) continue;
            f[b] = fac.finv(b) * fac.finv(B - b);
        }
        while (f.size() and f.back().val() == 0) f.pop_back();
        return f;
    };

    for (int bsum = 0; bsum < 3; bsum++) {
        auto h = atcoder::convolution(gen(B, bsum), gen(C, bsum));
        for (int w = 0; w < min(int(h.size()), N + 1); w++) dpsum[w] += h[w] * fac[w] * fac[B + C - w];
    }

    mint ret = 0;
    for (int n = 0; n <= N; n++) ret += dpsum[n] * fac.ncr(N, n) * fac.ncr(N, B + C - n);
    cout << ret.val() << '\n';
}
0