#P3359. 改造异或树
改造异或树
Description
You are given a tree with nodes, and each edge has a weight. Now we delete all edges one by one in a given order. After deleting each edge, query how many paths currently have the XOR sum of edge weights equal to .
Input Format
The first line contains an integer .
The next lines each contain three integers , with , indicating that there is an edge with weight between nodes numbered and .
The next line contains integers separated by single spaces, which form a permutation of , representing the deletion order of the edges.
Output Format
Output lines, each containing one integer. The -th line (where ) is the number of paths whose XOR sum of edge weights is after deleting the first edges in the given order.
4
1 2 0
2 3 0
2 4 0
3 1 2
6
3
1
0
Hint
For of the testdata, .
For another of the testdata, all .
For all testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号