#P5537. 【XR-3】系统设计
【XR-3】系统设计
Problem Description
Little X needs you to design a system.
This system first needs to read a rooted tree with nodes and a sequence of length , and then process operations.
There are two types of operations:
1 x l rmeans: set the starting point as node in the rooted tree, then traverse in order. When traversing to , move from the current node to its -th smallest child (by node index). If at some moment the current node has fewer than children, or you have already finished traversing , then stop at this node, output its index, and stop traversing.2 t kmeans: modify the -th number in the sequence, changing to .
Input Format
The first line contains positive integers , representing the number of nodes in the tree, the length of the sequence, and the number of operations.
The second line contains integers , where is the index of the parent of node in the tree. In particular, let the root be , then .
The third line contains positive integers , representing the sequence .
Then follow lines, each describing one operation.
Constraints:
- .
- .
- For operation type , it is guaranteed that , .
- For operation type , it is guaranteed that , .
Output Format
For each operation of type , output one positive integer per line, representing the answer.
6 6 10
0 1 2 2 1 5
1 2 2 1 2 1
1 1 1 3
1 5 2 6
1 6 5 6
1 2 3 5
1 2 4 4
2 2 1
1 1 1 6
1 1 2 4
2 1 2
1 1 1 5
4
5
6
4
3
3
4
6
Hint
The input and output size of this problem is large. Please use fast input/output.
Sample Explanation
The first operation is 1 1 1 3, that is, , so the answer is .
After the ninth operation, the sequence becomes 2 1 2 1 2 1.
The tenth operation is 1 1 1 5, that is, , so the answer is .
Translated by ChatGPT 5