#P16916. [JLCPC 2026] 计树

    ID: 19234 远端评测题 8000ms 1024MiB 尝试: 0 已通过: 0 显示难度NOI/NOI+/CTS 上传者: 标签>吉林O2优化2026省赛/邀请赛

[JLCPC 2026] 计树

Problem Description

You are given an integer KK, and two arrays a1,a2,…,a2K−1a_1, a_2, \ldots, a_{2^K - 1} and b1,b2,…,b2K−1b_1, b_2, \ldots, b_{2^K - 1}, each of length 2K−12^K - 1.

There is an undirected complete graph GG with 2K2^K vertices, labeled from 00 to 2K−12^K - 1.

For a spanning tree TT of graph GG, define

$$\begin{aligned} A(T) &= \prod_{(u,v)\in T} a_{u\oplus v},\\ B(T) &= \sum_{(u,v)\in T} b_{u\oplus v},\\ C(T) &= \bigoplus_{(u,v)\in T} (u\oplus v). \end{aligned}$$

For each 0≤x<2K0 \le x < 2^K, you need to compute

$$\left(\sum_{\substack{T\\ C(T)=x}} A(T)B(T)^p\right) \bmod 998244353,$$

where pp is a given constant.

It is defined that 00=10^0=1.

An undirected complete graph means there is an undirected edge between every pair of distinct vertices. A spanning tree means choosing some edges so that all vertices are connected and there is no cycle. The symbol ⊕\oplus denotes bitwise XOR.

Input Format

The first line contains two integers K,pK, p (1≤K≤161 \le K \le 16, 0≤p≤50 \le p \le 5).

The next line contains 2K−12^K - 1 integers; the ii-th integer denotes aia_i (0≤ai<9982443530 \le a_i < 998244353).

The next line contains 2K−12^K - 1 integers; the ii-th integer denotes bib_i (0≤bi<9982443530 \le b_i < 998244353).

Output Format

Output one line containing 2K2^K integers; the ii-th integer is the answer for x=i−1x = i - 1.

2 0
1 1 1
1 2 3
4 4 4 4
2 2
2 3 5
1 4 2
5880 5416 10464 9640

Hint

Translated by ChatGPT 5