#abc329f. F - Colored Ball
F - Colored Ball
Score : points
问题描述
有 个编号为 的盒子。最初,第 个盒子包含一个颜色为 的球。
你将收到 个查询请求,并需要按照顺序处理它们。
每个查询由一对整数 组成,要求你执行以下操作:
- 将盒子 中的所有球移动到盒子 ,然后打印出盒子 中不同颜色球的数量。
注意,盒子 和 可能是空的。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are boxes numbered . Initially, box contains one ball of color .
You are given queries, which you should process in order.
Each query is given by a pair of integers and asks you to do the following:
- Move all the balls from box to box , and then print the number of different colors of balls in box .
Here, the boxes and may be empty.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format, where represents the -th query:
Each query is given in the following format:
Output
Print lines. The -th line should contain the response to the -th query.
Sample Input 1
6 5
1 1 1 2 2 3
1 2
6 4
5 1
3 6
4 6
Sample Output 1
1
2
1
1
3
-
For the first query, move all the balls from box to box . Box now contains two balls of color , so print .
-
For the second query, move all the balls from box to box . Box now contains one ball of color and one ball of color , so print .
-
For the third query, move all the balls from box to box . Box now contains one ball of color , so print .
-
For the fourth query, move all the balls from box to box . Box now contains one ball of color , so print .
-
For the fifth query, move all the balls from box to box . Box now contains one ball of color , one ball of color , and one ball of color , so print .
Sample Input 2
5 3
2 4 2 4 2
3 1
2 5
3 2
Sample Output 2
1
2
0
update @ 2024/3/10 01:54:41