結果
問題 | No.1503 Bitwise And Convolution Twisted |
ユーザー |
![]() |
提出日時 | 2021-05-07 22:19:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 399 ms / 2,000 ms |
コード長 | 1,069 bytes |
コンパイル時間 | 4,128 ms |
コンパイル使用メモリ | 253,456 KB |
最終ジャッジ日時 | 2025-01-21 08:21:18 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 |
ソースコード
#include<bits/stdc++.h> using namespace std; #include<atcoder/all> using namespace atcoder; istream &operator>>(istream &is, modint998244353 &a) { long long v; is >> v; a = v; return is; } ostream &operator<<(ostream &os, const modint998244353 &a) { return os << a.val(); } #define rep_(i, a_, b_, a, b, ...) for (int i = (a), lim##i = (b); i < lim##i; ++i) #define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__) template<class T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; } template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; } struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); }; } fast_ios_; int main() { int n; cin >> n; int N = 1<<n; vector<modint998244353> a(N), b(N); cin >> a >> b; rep(i, n) rep(S, N) if (S>>i&1) b[S] -= b[S^(1<<i)]; rep(i, n) rep(S, N) if (S>>i&1) a[S^(1<<i)] += a[S]; rep(S, N) a[S] *= b[S]; rep(i, n) rep(S, N) if (S>>i&1) a[S] += a[S^(1<<i)]; cout << a << '\n'; }