結果

問題 No.2164 Equal Balls
ユーザー KumaTachiRenKumaTachiRen
提出日時 2023-09-22 16:06:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3,087 ms / 5,000 ms
コード長 2,020 bytes
コンパイル時間 7,145 ms
コンパイル使用メモリ 267,840 KB
実行使用メモリ 6,932 KB
最終ジャッジ日時 2023-09-22 16:07:25
合計ジャッジ時間 72,400 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 430 ms
4,380 KB
testcase_09 AC 165 ms
4,376 KB
testcase_10 AC 100 ms
4,376 KB
testcase_11 AC 753 ms
4,376 KB
testcase_12 AC 447 ms
4,384 KB
testcase_13 AC 152 ms
4,376 KB
testcase_14 AC 395 ms
4,380 KB
testcase_15 AC 735 ms
4,376 KB
testcase_16 AC 444 ms
4,376 KB
testcase_17 AC 31 ms
4,376 KB
testcase_18 AC 563 ms
4,376 KB
testcase_19 AC 1,823 ms
5,144 KB
testcase_20 AC 496 ms
4,380 KB
testcase_21 AC 23 ms
4,380 KB
testcase_22 AC 12 ms
4,380 KB
testcase_23 AC 494 ms
4,668 KB
testcase_24 AC 2,112 ms
5,640 KB
testcase_25 AC 351 ms
4,408 KB
testcase_26 AC 2,161 ms
5,260 KB
testcase_27 AC 2,464 ms
5,696 KB
testcase_28 AC 2,430 ms
5,784 KB
testcase_29 AC 258 ms
4,376 KB
testcase_30 AC 978 ms
4,984 KB
testcase_31 AC 513 ms
4,864 KB
testcase_32 AC 2,254 ms
5,852 KB
testcase_33 AC 295 ms
4,376 KB
testcase_34 AC 457 ms
4,548 KB
testcase_35 AC 68 ms
4,380 KB
testcase_36 AC 2,605 ms
6,596 KB
testcase_37 AC 572 ms
4,928 KB
testcase_38 AC 2,999 ms
6,752 KB
testcase_39 AC 2,975 ms
6,696 KB
testcase_40 AC 3,004 ms
6,752 KB
testcase_41 AC 3,061 ms
6,932 KB
testcase_42 AC 3,000 ms
6,668 KB
testcase_43 AC 3,009 ms
6,732 KB
testcase_44 AC 3,050 ms
6,636 KB
testcase_45 AC 3,079 ms
6,668 KB
testcase_46 AC 3,087 ms
6,748 KB
testcase_47 AC 3,015 ms
6,896 KB
testcase_48 AC 2,995 ms
6,720 KB
testcase_49 AC 679 ms
4,676 KB
testcase_50 AC 679 ms
4,692 KB
testcase_51 AC 680 ms
4,912 KB
testcase_52 AC 678 ms
4,984 KB
testcase_53 AC 682 ms
4,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

struct Fast {
  Fast() {
    std::cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(10);
  }
} fast;

#define all(a) (a).begin(), (a).end()
#define contains(a, x) ((a).find(x) != (a).end())
#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (int)(b)-1; i >= (a); i--)
#define writejoin(s, a) rep(_i, 0, (a).size()) cout << (a)[_i] << (_i + 1 < (int)(a).size() ? s : "\n");
#define YN(b) cout << ((b) ? "YES" : "NO") << "\n";
#define Yn(b) cout << ((b) ? "Yes" : "No") << "\n";
#define yn(b) cout << ((b) ? "yes" : "no") << "\n";

template <typename mint>
class Factorial {
 public:
  Factorial(int max) : n(max) {
    f = vector<mint>(n + 1);
    finv = vector<mint>(n + 1);
    f[0] = 1;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i;
    finv[n] = f[n].inv();
    for (int i = n; i > 0; i--) finv[i - 1] = finv[i] * i;
  }
  mint fact(int k) {
    assert(0 <= k && k <= n);
    return f[k];
  }
  mint fact_inv(int k) {
    assert(0 <= k && k <= n);
    return finv[k];
  }
  mint binom(int k, int r) {
    assert(0 <= k && k <= n);
    if (r < 0 || r > k) return 0;
    return f[k] * finv[r] * finv[k - r];
  }
  mint inv(int k) {
    assert(0 < k && k <= n);
    return finv[k] * f[k - 1];
  }

 private:
  int n;
  vector<mint> f, finv;
};

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using mint = modint998244353;

int main() {
  const int l = 300;
  int n, m;
  cin >> n >> m;

  vi a(n), b(n);
  rep(i, 0, n) cin >> a[i];
  rep(i, 0, n) cin >> b[i];

  Factorial<mint> fact(10000);

  vector<mint> f(m * l + 1);
  f[0] = 1;
  rep(k, 0, m) {
    vector<mint> c(2 * l + 1, 1);
    for (int i = k; i < n; i += m)
      for (int j = -l; j <= l; j++)
        c[j + l] *= fact.binom(a[i] + b[i], j + b[i]);
    f = convolution(f, c);
    f.resize(m * l + 1);
  }
  cout << f[l * m].val() << "\n";
}
0