#P6053. [RC-02] XOR
[RC-02] XOR
Description
Note: In this problem, every means taking the XOR-sum.
There is a rooted tree with nodes and edges. Initially, node is the root.
Each node on the tree has a node value .
Define the function $\operatorname{Xor}(x)=\sum_{y\in \operatorname{Subtree}(x)}{V_{y}}$, where denotes the subtree of .
You need to support the following five operations:
1 x: Make the root, and query .2 x y: Set .3 x y: Query .4 x y: Query the XOR-sum of node values along the path from to .5 x: Query .
Input Format
The first line contains three integers , representing the number of nodes, the number of operation type , and the number of the remaining operations.
The next line contains integers, representing .
The next lines each contain two integers , indicating that there is an edge between and .
The next lines each contain two or three integers. The first number is the operation type, followed by the parameters of that operation.
Output Format
Output several lines, each being the result of operations .
5 4 4
0 0 2 2 1
1 2
1 3
2 4
2 5
1 1
1 1
1 1
2 3 0
4 3 3
5 1
1 2
3 1 2
3
3
3
0
3
0
2
10 8 8
5 6 2 1 0 4 0 0 0 3
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
3 10 9
2 1 6
1 5
1 4
1 7
1 7
5 1
1 1
3 1 5
1 7
1 9
2 5 0
4 9 6
1 10
4 10 7
5 1
2
3
3
3
3
2
3
1
3
7
7
7
1
0
Hint
For all testdata, it is guaranteed that , . The detailed Constraints are shown in the table below.
| Test Point ID | Time Limit / s | |||
|---|---|---|---|---|
Translated by ChatGPT 5
京公网安备 11011102002149号