#P10461. 【模板】多项式复合集合幂级数

    ID: 13470 远端评测题 5000ms 512MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>快速沃尔什变换 FWT快速莫比乌斯变换 FMT集合幂级数,子集卷积

【模板】多项式复合集合幂级数

Problem Description

Given a set power series F(x)F(x) and a polynomial G(x)G(x), it is guaranteed that [x]F(x)=0[x^{\varnothing}]F(x)=0. Define the multiplication of xx as subset convolution. You need to compute, for every S{1,2,,n}S\subseteq\{1,2,\cdots,n\}, the value of [xS]G(F(x))[x^S]G(F(x)) modulo 998244353998244353.

If you still do not understand the statement, you can read the hint section at the end.

Input Format

The first line contains a positive integer nn.

The next line contains 2n2^n non-negative integers. The ii-th integer denotes [xS]F(x)[x^S]F(x), where aSa\in S if and only if, in the binary representation of (i1)(i-1), the aa-th bit (from low to high) is 11.

The next line contains n+1n+1 non-negative integers. The ii-th integer denotes [xi1]G(x)[x^{i-1}]G(x).

Output Format

Output one line containing 2n2^n non-negative integers. The ii-th integer denotes [xS]G(F(x))[x^S]G(F(x)) modulo 998244353998244353, where aSa\in S if and only if, in the binary representation of (i1)(i-1), the aa-th bit (from low to high) is 11.

2
0 1 2 3
2 1 1
2 1 2 7
4
0 8 3 2 7 3 9 0 0 1 8 2 3 7 0 2
1 0 4 8 2
1 0 0 192 0 448 168 8824 0 0 0 536 0 248 520 26560 

Hint

Constraints

For all testdata, it is guaranteed that 1n201\le n\le 20, and [xS]F(x),[xn]G(x)[0,998244353)Z[x^S]F(x),[x^n]G(x)\in[0,998244353)\cap\mathbb Z.

This problem has 2020 test points. For the ii-th test point, n=in=i.

Hint

Suppose F(x)=SfSxSF(x)=\displaystyle \sum_S f_Sx^S, then [xS]F(x)=fS[x^S]F(x)=f_S.

In this problem, the multiplication of xx is defined as subset convolution, i.e.:

$$x^S\cdot x^T=\begin{cases}0&S\cap T\neq\varnothing\\x^{S\cup T}&\text{otherwise}\end{cases}$$

Please pay attention to the efficiency differences caused by contiguous memory access.

Translated by ChatGPT 5