#P13308. 故障
故障
Description
Yuki has a full binary tree with levels. The nodes are numbered according to a level-order traversal (see explanation).
This tree undergoes operations.
-
The tree experiences a fault. The edge between node and its parent is deleted. If the node is the root or this edge has already been deleted, nothing happens.
-
Query the size of the connected component containing node .
Input Format
The first line contains two integers and .
The next lines each contain two integers and .
If , perform operation 1 on . If , perform operation 2 on .
Output Format
To simplify the output, you only need to print one line, representing the XOR of all answers for each query.
5 3
2 3
1 3
2 3
16
5 3
1 2
1 3
2 1
1
Hint
Binary Tree and Related Issues
- A full binary tree with levels refers to a full binary tree with a maximum depth of , where the root node has a depth of 1.
- If node has children, the level-order traversal numbering of the full binary tree satisfies that the left child of is and the right child is .
Explanation for Sample 1
For the first query, before deleting the edge between 3 and 1, the answer is the size of the entire tree, which is 31. After deletion, it becomes the size of 3's subtree, which is 15. The XOR sum is .
Data Range
There are 10 test cases.
For the first 20% of the data, .
For the first 50% of the data, .
For the first 80% of the data, .
For all data, $2 \leq n \leq 60, 1 \leq m \leq 3 \times 10^5, 1 \leq o \leq 2, 1 \leq u \leq 2^n -1$.
京公网安备 11011102002149号