#P5889. 跳树
跳树
Description
One day, a rabbit is on a node of a perfect binary tree with nodes, and he plans to perform several jumps of the following types:
- Jump to the left child of the current node. It is guaranteed that the node has a left child.
- Jump to the right child of the current node. It is guaranteed that the node has a right child.
- Jump to the parent of the current node. If the current node is the root, ignore this operation.
For node , it either has no children, or it has a left child and a right child .
The rabbit will jump in a planned way. He writes down a sequence of length . Each number in is one of , , or . Operation corresponds to the -th jump type listed above from top to bottom.
Each time, the rabbit chooses an interval and performs the jumps in order.
Sometimes, the rabbit will modify the value at a position.
Now you need to determine which node the rabbit ends up at for each query.
Reading the sample explanation can help you understand the statement better.
Input Format
The first line contains three integers , representing the exponent determining the tree size, the length of , and the number of operations.
The second line contains integers , representing the initial sequence.
The next lines each contain an integer . If is , then three integers follow, describing the starting node and the interval of jumps to perform. If is , then two integers follow, describing the position to modify and the new value.
Output Format
For each query with , output one number, the node where the rabbit ends up after the jumps.
3 5 4
1 2 3 3 1
1 3 4 5
1 2 2 4
2 3 1
1 1 2 3
2
1
6
Hint

The red edges show the path of the first jump, the blue edges the second, and the green edges the third.
The constraints and characteristics of all testdata are shown in the table below:

For of the data, , , and .
Translated by ChatGPT 5
京公网安备 11011102002149号