#abc366c. C - Balls and Bag Query

C - Balls and Bag Query

Score : 300300 points

问题陈述

你有一个空袋子。你将收到 QQ 个查询,这些查询必须按顺序处理。

有三种类型的查询。

  • 1 x : 将一个写有整数 xx 的球放入袋子中。
  • 2 x : 从袋子中取出一个写有整数 xx 的球并丢弃它。当给出这个查询时,保证袋子里有一个写有整数 xx 的球。
  • 3 : 打印袋子中球上写的不同整数的数量。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

You have an empty bag. You are given QQ queries, which must be processed in order.

There are three types of queries.

  • 1 x : Put one ball with the integer xx written on it into the bag.
  • 2 x : Remove one ball with the integer xx written on it from the bag and discard it. It is guaranteed that the bag has a ball with the integer xx written on it when this query is given.
  • 3 : Print the number of different integers written on the balls in the bag.

Constraints

  • 1Q2×1051 \leq Q \leq 2 \times 10^{5}
  • 1x1061 \leq x \leq 10^{6}
  • When a query of the second type is given, the bag has a ball with the integer xx 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:

QQ

query1\text{query}_1

query2\text{query}_2

\vdots

queryQ\text{query}_Q

The ii-th query queryi\text{query}_i is given in one of the following three formats:

11 xx

22 xx

33

Output

If there are KK queries of the third type, print KK lines. The ii-th line (1iK)(1 \leq i \leq K) should contain the answer to the ii-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 33 written on it enters the bag.

For the second query 1 1, a ball with the integer 11 written on it enters the bag.

For the third query 1 4, a ball with the integer 44 written on it enters the bag.

For the fourth query 3, the bag has balls with the integers 1,3,41, 3, 4, so print 33.

For the fifth query 2 1, a ball with the integer 11 written on it is removed from the bag.

For the sixth query 3, the bag has balls with the integers 3,43, 4, so print 22.

For the seventh query 1 5, a ball with the integer 55 written on it enters the bag.

For the eighth query 3, the bag has balls with the integers 3,4,53, 4, 5, so print 33.

Sample Input 2

8
1 2
1 2
3
2 2
1 4
1 4
2 2
3

Sample Output 2

1
1