結果
| 問題 | No.1503 Bitwise And Convolution Twisted | 
| コンテスト | |
| ユーザー |  cureskol | 
| 提出日時 | 2024-10-31 10:38:46 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1,032 ms / 2,000 ms | 
| コード長 | 1,876 bytes | 
| コンパイル時間 | 4,384 ms | 
| コンパイル使用メモリ | 258,932 KB | 
| 実行使用メモリ | 17,236 KB | 
| 最終ジャッジ日時 | 2024-10-31 10:39:00 | 
| 合計ジャッジ時間 | 13,485 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 9 | 
ソースコード
#include <atcoder/modint>
#include <bits/stdc++.h>
using mint = atcoder::modint998244353;
template <typename T> void zeta(std::vector<T> &v) {
    int N = v.size();
    assert(std::popcount(unsigned(N)) == 1);
    for (int i = 1; i < N; i <<= 1)
        for (int S = 0; S < N; S++)
            if (S & i)
                v[S] += v[S - i];
}
template <typename T> void transposition_zeta(std::vector<T> &v) {
    int N = v.size();
    assert(std::popcount(unsigned(N)) == 1);
    std::ranges::reverse(v);
    zeta(v);
    std::ranges::reverse(v);
}
template <typename T> void mobius(std::vector<T> &v) {
    int N = v.size();
    assert(std::popcount(unsigned(N)) == 1);
    for (int i = N >> 1; i; i >>= 1)
        for (int S = N - 1; S >= 0; S--)
            if (S & i)
                v[S] -= v[S - i];
}
template <typename T> void transposition_mobius(std::vector<T> &v) {
    int N = v.size();
    assert(std::popcount(unsigned(N)) == 1);
    std::ranges::reverse(v);
    mobius(v);
    std::ranges::reverse(v);
}
template <typename T>
std::vector<T> hadamard_product(const std::vector<T> &v,
                                const std::vector<T> &w) {
    int N = v.size();
    assert(v.size() == w.size());
    std::vector<mint> result;
    std::ranges::transform(v, w, std::back_inserter(result),
                           [](mint a, mint b) { return a * b; });
    return result;
}
int main() {
    int n;
    std::cin >> n;
    std::vector<mint> a(1 << n), b(1 << n);
    for (mint &x : a) {
        int x_;
        std::cin >> x_;
        x = mint::raw(x_);
    }
    for (mint &x : b) {
        int x_;
        std::cin >> x_;
        x = mint::raw(x_);
    }
    transposition_zeta(a);
    mobius(b);
    auto c = hadamard_product(a, b);
    zeta(c);
    for (int i = 0; i < (1 << n); i++)
        std::cout << c[i].val() << "\n "[i + 1 < (1 << n)];
}
            
            
            
        