結果
| 問題 |
No.2164 Equal Balls
|
| コンテスト | |
| ユーザー |
trineutron
|
| 提出日時 | 2022-12-15 12:13:25 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,196 bytes |
| コンパイル時間 | 3,196 ms |
| コンパイル使用メモリ | 255,400 KB |
| 実行使用メモリ | 13,860 KB |
| 最終ジャッジ日時 | 2024-11-14 02:26:11 |
| 合計ジャッジ時間 | 223,445 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | WA * 19 TLE * 32 |
ソースコード
#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;
}
trineutron