#P10799. 「CZOI-R1」三角形与树
「CZOI-R1」三角形与树
Background
CaiZi hates triangles, but he likes trees.
2024.8.15 Update: Added a set of hack testdata.
Problem Description
Given a tree with nodes, numbered from to . Each node has a weight, and initially the weight of node is . There are operations in total.
- XOR the weights of all nodes on the simple path from node to node by .
- Determine whether it is possible to choose distinct nodes on the simple path from node to node , and use the weights of these nodes as side lengths to form a triangle. In particular, if it is impossible to choose nodes, it is also considered impossible to form a triangle.
The simple path from node to node is the path from to that does not traverse any edge more than once. All nodes on it are the nodes on this path, including node and node .
It is guaranteed that at any time, no node will have weight .
Input Format
The first line contains integers , representing the number of nodes in the tree and the number of operations.
The second line contains integers , representing the initial weight of node .
The next lines each contain integers , representing an edge of the tree.
The next lines each start with integer , representing the operation type.
- If , then read integers , representing an update operation.
- If , then read integers , representing a query operation.
Output Format
For each query operation, output if the condition can be satisfied; otherwise output . Output all answers consecutively, with no spaces or newlines.
5 5
1 2 3 4 5
1 2
1 3
2 4
2 5
2 1 2
2 3 4
1 3 5 4
2 2 3
2 1 5
0110
Hint
Sample Explanation
In the 1st operation, there are fewer than node weights on the simple path.
In the 2nd operation, the node weights on the simple path are .
After the 3rd operation, the node weights of nodes are .
In the 4th operation, the node weights on the simple path are .
In the 5th operation, the node weights on the simple path are .
Constraints
This problem uses bundled tests.
- Subtask #1 (): .
- Subtask #2 (): The tree is guaranteed to be a "chrysanthemum" (juhua).
- Subtask #3 (): In every update operation, .
- Subtask #4 (): The tree is guaranteed to be a chain.
- Subtask #5 (): No special properties. Depends on Subtask #1 to Subtask #4.
For of the data, , , , and .
Translated by ChatGPT 5