結果

問題 No.2164 Equal Balls
ユーザー trineutrontrineutron
提出日時 2022-12-15 12:13:25
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,196 bytes
コンパイル時間 4,000 ms
コンパイル使用メモリ 282,860 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-26 14:06:38
合計ジャッジ時間 11,559 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
9,344 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include <atcoder/modint>

using namespace std;
using namespace atcoder;

using mint = modint998244353;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(n);
    for (auto &&x : a) {
        cin >> x;
    }
    for (auto &&x : b) {
        cin >> x;
    }

    int offset = 300;
    vector<vector<mint>> count(m, vector<mint>(2 * offset + 1, 1));
    for (int i = 0; i < n; i++) {
        for (int j = -offset; j <= offset; j++) {
            count.at(i % m).at(j + offset) *=
                max(-1, min({a.at(i), b.at(i), j + a.at(i), b.at(i) - j})) + 1;
        }
    }

    int offset2 = 300 * m;
    vector<mint> ans(2 * offset2 + 1);
    ans.at(offset2) = 1;
    for (int i = 0; i < m; i++) {
        vector<mint> ans_new(2 * offset2 + 1);
        for (int j = 0; j <= 2 * offset2; j++) {
            for (int k = -offset; k <= offset; k++) {
                int j_next = j + k;
                if (j_next < 0 or 2 * offset2 < j_next) continue;
                ans_new.at(j_next) += ans.at(j) * count.at(i).at(k + offset);
            }
        }
        ans = move(ans_new);
    }

    cout << ans.at(offset2).val() << endl;

    return 0;
}
0