結果

問題 No.2164 Equal Balls
ユーザー t98slidert98slider
提出日時 2022-12-16 10:44:23
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 432 ms / 5,000 ms
コード長 1,228 bytes
コンパイル時間 3,273 ms
コンパイル使用メモリ 147,724 KB
実行使用メモリ 16,896 KB
最終ジャッジ日時 2023-08-09 18:55:31
合計ジャッジ時間 17,410 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 4 ms
4,376 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 46 ms
7,740 KB
testcase_09 AC 34 ms
6,424 KB
testcase_10 AC 18 ms
5,428 KB
testcase_11 AC 88 ms
11,004 KB
testcase_12 AC 49 ms
8,060 KB
testcase_13 AC 31 ms
6,376 KB
testcase_14 AC 39 ms
7,008 KB
testcase_15 AC 86 ms
11,024 KB
testcase_16 AC 41 ms
7,188 KB
testcase_17 AC 12 ms
4,924 KB
testcase_18 AC 61 ms
8,896 KB
testcase_19 AC 104 ms
12,736 KB
testcase_20 AC 56 ms
8,520 KB
testcase_21 AC 8 ms
4,508 KB
testcase_22 AC 8 ms
4,488 KB
testcase_23 AC 132 ms
6,992 KB
testcase_24 AC 164 ms
14,312 KB
testcase_25 AC 107 ms
5,656 KB
testcase_26 AC 140 ms
14,468 KB
testcase_27 AC 197 ms
15,476 KB
testcase_28 AC 196 ms
15,476 KB
testcase_29 AC 63 ms
6,512 KB
testcase_30 AC 154 ms
11,452 KB
testcase_31 AC 152 ms
6,536 KB
testcase_32 AC 190 ms
14,692 KB
testcase_33 AC 81 ms
5,584 KB
testcase_34 AC 118 ms
7,216 KB
testcase_35 AC 21 ms
4,376 KB
testcase_36 AC 286 ms
15,524 KB
testcase_37 AC 166 ms
6,008 KB
testcase_38 AC 428 ms
16,764 KB
testcase_39 AC 430 ms
16,628 KB
testcase_40 AC 428 ms
16,676 KB
testcase_41 AC 428 ms
16,672 KB
testcase_42 AC 427 ms
16,632 KB
testcase_43 AC 430 ms
16,740 KB
testcase_44 AC 431 ms
16,708 KB
testcase_45 AC 431 ms
16,628 KB
testcase_46 AC 432 ms
16,896 KB
testcase_47 AC 431 ms
16,672 KB
testcase_48 AC 431 ms
16,736 KB
testcase_49 AC 294 ms
5,444 KB
testcase_50 AC 297 ms
5,528 KB
testcase_51 AC 295 ms
5,704 KB
testcase_52 AC 296 ms
5,892 KB
testcase_53 AC 293 ms
5,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint = modint998244353;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M, r = 600;
    cin >> N >> M;
    vector<int> A(N), B(N);
    for(auto &&v:A)cin >> v;
    for(auto &&v:B)cin >> v;

    vector<vector<mint>> comb(r + 1), tb(M, vector<mint>(r + 1, 1));
    for(int i = 1; i <= r; i++){
        comb[i].resize(i + 1);
        comb[i][0] = comb[i][i] = 1;
        for(int j = 1; j < i; j++) comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
    }

    for(int i = 0; i < M; i++){
        for(int k = i; k < N; k += M){
            for(int j = -B[k]; j <= A[k]; j++) tb[i][j + 300] *= comb[A[k] + B[k]][B[k] + j];
            for(int j = A[k] + 1; j <= 300; j++) tb[i][j + 300] = 0;
            for(int j = B[k] + 1; j <= 300; j++) tb[i][-j + 300] = 0;
        }
    }

    int s = 300 * M + 1;
    auto merge = [&](int i, int j){
        if(j >= M)return;
        tb[i] = convolution(tb[i], tb[j]);
        if(tb[i].size() > s) tb[i].resize(s);
    };

    for(int i = 0; i < 9; i++){
        int d = 1 << i + 1;
        for(int j = 0; j < M; j += d) merge(j, j + (1 << i));
    }
    cout << tb[0][300 * M].val() << '\n';
}
0