#abc279f. F - BOX
F - BOX
Score : points
问题描述
有 个编号为 的盒子,以及 个编号为 的球。初始时,第 个盒子仅包含球 。
总共需要处理 个操作。
操作分为三种类型:、 和 。
类型 : 将盒子 中的所有内容放入盒子 。保证 。
1 $X$ $Y$
类型 : 将当前盒子中球总数为 时的下一个球(即球 )放入盒子 。
2 $X$
类型 : 报告包含球 的盒子的编号。
3 $X$
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are boxes numbered , and balls numbered . Initially, box contains just ball .
Process a total of operations that will be performed.
There are three types of operations: , , and .
Type : Put all contents of box into box . It is guaranteed that .
1 $X$ $Y$
Type : Put ball into box , where is the current total number of balls contained in the boxes.
2 $X$
Type : Report the number of the box that contains ball .
3 $X$
Constraints
- All values in the input are integers.
- For each type- operation, and .
- For each type- operation, .
- For each type- operation, ball is contained in some box at that point.
- There is at least one type- operation.
Input
The input is given from Standard Input in the following format.
Here, represents the -th operation.
Output
For each type- operation, print a line containing the response as an integer.
Sample Input 1
5 10
3 5
1 1 4
2 1
2 4
3 7
1 3 1
3 4
1 1 4
3 7
3 6
Sample Output 1
5
4
3
1
3
This input contains ten operations.
- The first operation is of type . Ball is in box .
- The second operation is of type . Put all contents of box into box .
- Box now contains balls and , and box is now empty.
- The third operation is of type . Put ball into box .
- The fourth operation is of type . Put ball into box .
- The fifth operation is of type . Ball is in box .
- The sixth operation is of type . Put all contents of box into box .
- Box now contains balls , , , and , and box is now empty.
- The seventh operation is of type . Ball is in box .
- The eighth operation is of type . Put all contents of box into box .
- Box now contains ball , and box is now empty.
- The ninth operation is of type . Ball is in box .
- The tenth operation is of type . Ball is in box .
update @ 2024/3/10 11:45:06