#abc366c. C - Balls and Bag Query
C - Balls and Bag Query
Score : points
问题陈述
你有一个空袋子。你将收到 个查询,这些查询必须按顺序处理。
有三种类型的查询。
1 x
: 将一个写有整数 的球放入袋子中。2 x
: 从袋子中取出一个写有整数 的球并丢弃它。当给出这个查询时,保证袋子里有一个写有整数 的球。3
: 打印袋子中球上写的不同整数的数量。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
You have an empty bag. You are given queries, which must be processed in order.
There are three types of queries.
1 x
: Put one ball with the integer written on it into the bag.2 x
: Remove one ball with the integer written on it from the bag and discard it. It is guaranteed that the bag has a ball with the integer written on it when this query is given.3
: Print the number of different integers written on the balls in the bag.
Constraints
- When a query of the second type is given, the bag has a ball with the integer written on it.
- There is at least one query of the third type.
- All input values are integers.
Input
The input is given from Standard Input in the following format:
The -th query is given in one of the following three formats:
Output
If there are queries of the third type, print lines. The -th line should contain the answer to the -th query of the third type.
Sample Input 1
8
1 3
1 1
1 4
3
2 1
3
1 5
3
Sample Output 1
3
2
3
Initially, the bag is empty.
For the first query 1 3
, a ball with the integer written on it enters the bag.
For the second query 1 1
, a ball with the integer written on it enters the bag.
For the third query 1 4
, a ball with the integer written on it enters the bag.
For the fourth query 3
, the bag has balls with the integers , so print .
For the fifth query 2 1
, a ball with the integer written on it is removed from the bag.
For the sixth query 3
, the bag has balls with the integers , so print .
For the seventh query 1 5
, a ball with the integer written on it enters the bag.
For the eighth query 3
, the bag has balls with the integers , so print .
Sample Input 2
8
1 2
1 2
3
2 2
1 4
1 4
2 2
3
Sample Output 2
1
1