結果
問題 | No.1068 #いろいろな色 / Red and Blue and more various colors (Hard) |
ユーザー | trineutron |
提出日時 | 2020-05-29 23:11:32 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,755 bytes |
コンパイル時間 | 2,509 ms |
コンパイル使用メモリ | 204,440 KB |
実行使用メモリ | 67,064 KB |
最終ジャッジ日時 | 2024-04-24 01:06:01 |
合計ジャッジ時間 | 10,381 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
13,752 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 659 ms
6,940 KB |
testcase_04 | AC | 229 ms
6,940 KB |
testcase_05 | AC | 226 ms
6,940 KB |
testcase_06 | AC | 227 ms
6,940 KB |
testcase_07 | AC | 229 ms
6,940 KB |
testcase_08 | AC | 228 ms
6,940 KB |
testcase_09 | AC | 231 ms
6,940 KB |
testcase_10 | AC | 80 ms
6,940 KB |
testcase_11 | AC | 227 ms
6,940 KB |
testcase_12 | AC | 79 ms
6,944 KB |
testcase_13 | TLE | - |
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 | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; constexpr int64_t mod = 998244353; vector<int64_t> mul(const vector<int64_t> &a, const vector<int64_t> &b) { int n = a.size(); if (n == 1) return { a.at(0) * b.at(0) % mod, 0 }; vector<int64_t> al(n / 2), ah(n / 2), as(n / 2), bl(n / 2), bh(n / 2), bs(n / 2); for (int i = 0; i < n / 2; i++) { al.at(i) = a.at(i); ah.at(i) = a.at(i + n / 2); as.at(i) = (al.at(i) + ah.at(i)) % mod; bl.at(i) = b.at(i); bh.at(i) = b.at(i + n / 2); bs.at(i) = (bl.at(i) + bh.at(i)) % mod; } vector<int64_t> l = mul(al, bl), h = mul(ah, bh), s = mul(as, bs); for (int i = 0; i < n; i++) { s.at(i) += 2 * mod - l.at(i) - h.at(i); s.at(i) %= mod; } vector<int64_t> res(2 * n); for (int i = 0; i < n; i++) { res.at(i) += l.at(i); res.at(i + n / 2) += s.at(i); res.at(i + n) += h.at(i); } for (int i = 0; i < 2 * n; i++) { res.at(i) %= mod; } return res; } int main() { int n, q; cin >> n >> q; vector<int64_t> a(n), b(q); for (int i = 0; i < n; i++) { cin >> a.at(i); a.at(i) %= mod; } for (int i = 0; i < q; i++) { cin >> b.at(i); } int m = 1, d = 1; while (m < n) m *= 2; vector<vector<int64_t>> c(m); for (int i = 0; i < m; i++) { if (i < n) { c.at(i) = { (a.at(i) + mod - 1) % mod, 1 }; } else { c.at(i) = { 1, 0 }; } } while (d < m) { for (int i = 0; i < m; i += 2 * d) { c.at(i) = mul(c.at(i), c.at(i + d)); } d *= 2; } for (int i = 0; i < q; i++) { cout << c.at(0).at(b.at(i)) << endl; } }