結果
問題 | No.1068 #いろいろな色 / Red and Blue and more various colors (Hard) |
ユーザー | tonyu0 |
提出日時 | 2020-08-02 10:21:01 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,899 bytes |
コンパイル時間 | 1,107 ms |
コンパイル使用メモリ | 109,980 KB |
実行使用メモリ | 4,752 KB |
最終ジャッジ日時 | 2023-09-25 10:15:20 |
合計ジャッジ時間 | 10,246 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
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 <algorithm> #include <cmath> #include <complex> #include <iomanip> #include <iostream> #include <queue> #include <set> #include <vector> using namespace std; using ll = int64_t; #define rep(i, j, n) for (int i = j; i < (int)n; ++i) constexpr ll MOD = 998244353; namespace fft { using C = complex<long double>; const long double PI = 3.14159265358979323846; void fft(vector<C>& f, int n, int sgn = 1) { if (n == 1) return; vector<C> f0(n / 2), f1(n / 2); for (int i = 0; i < n / 2; ++i) { f0[i] = f[i * 2]; f1[i] = f[i * 2 + 1]; } fft(f0, n / 2, sgn); fft(f1, n / 2, sgn); C zeta = {cos(2.0 * PI / (long double)n), sin(2.0 * PI / (long double)n) * sgn}; C now = {1.0, 0.0}; for (int i = 0; i < n; ++i) { f[i] = f0[i % (n / 2)] + now * f1[i % (n / 2)]; now *= zeta; } } template <typename T> vector<T> multiply(vector<T> a, vector<T> b) { int n = (int)a.size() + (int)b.size() - 1; int nn = 1; while (nn < n) nn <<= 1; vector<C> f(nn), g(nn); for (int i = 0; i < (int)a.size(); ++i) f[i] = {(long double)a[i], 0.0}; for (int i = 0; i < (int)b.size(); ++i) g[i] = {(long double)b[i], 0.0}; fft(f, nn); fft(g, nn); for (int i = 0; i < nn; ++i) f[i] = f[i] * g[i]; // inverse fft(f, nn, -1); vector<T> c(n); for (int i = 0; i < n; ++i) c[i] = (T)fmod(f[i].real() / (long double)nn + 0.5, (long double)MOD); return c; } } // namespace fft vector<ll> solve(vector<ll> a) { int n = a.size(); if (n == 1) return {1, (a[0] - 1) % MOD}; vector<ll> f(a.begin(), a.begin() + n / 2); vector<ll> g(a.begin() + n / 2, a.end()); return fft::multiply(solve(f), solve(g)); } int main() { int n, q, b; cin >> n >> q; vector<ll> a(n); rep(i, 0, n) cin >> a[i]; vector<ll> c = solve(a); reverse(c.begin(), c.end()); rep(i, 0, q) { cin >> b; cout << c[b] % MOD << '\n'; } return 0; }