結果
問題 |
No.2164 Equal Balls
|
ユーザー |
![]() |
提出日時 | 2022-12-15 12:14:13 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,206 bytes |
コンパイル時間 | 3,243 ms |
コンパイル使用メモリ | 254,504 KB |
実行使用メモリ | 13,640 KB |
最終ジャッジ日時 | 2024-11-14 02:31:00 |
合計ジャッジ時間 | 212,827 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | WA * 20 TLE * 31 |
ソースコード
#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 = (m + 1) / 2 * 300; 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; }