#P16916. [JLCPC 2026] 计树
[JLCPC 2026] 计树
Problem Description
You are given an integer , and two arrays and , each of length .
There is an undirected complete graph with vertices, labeled from to .
For a spanning tree of graph , 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 , you need to compute
$$\left(\sum_{\substack{T\\ C(T)=x}} A(T)B(T)^p\right) \bmod 998244353,$$where is a given constant.
It is defined that .
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 denotes bitwise XOR.
Input Format
The first line contains two integers (, ).
The next line contains integers; the -th integer denotes ().
The next line contains integers; the -th integer denotes ().
Output Format
Output one line containing integers; the -th integer is the answer for .
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