P26041 [AtCoder] [ABC366C] Balls and Bag Query
入门
题目描述

Problem Description

There is an empty bag. You are given $Q$ queries, and you need to process them in order.

There are three types of queries:

  • 1 x: Put one ball with the integer $x$ written on it into the bag.
  • 2 x: Take one ball with the integer $x$ written on it out of the bag and discard it. It is guaranteed that there is at least one ball with the integer $x$ in the bag when this query is given.
  • 3: Output the number of different integers written on the balls in the bag.

Input Format

The input is given from the standard input in the following format:

$Q$ $query_1$ $query_2$ $\vdots$ $query_Q$

The $i$-th query $query_i$ is given in one of the following three formats:

$1$ $x$

$2$ $x$

$3$

Output Format

When there are $K$ queries of the third type, output $K$ lines. On the $i$-th line $(1 \leq i \leq K)$, output the answer for the $i$-th query of the third type.

Sample Input and Output

Sample Input #1

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

Sample Output #1

3
2
3

Sample Input #2

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

Sample Output #2

1
1

Notes/Hints

Constraints

  • $1 \leq Q \leq 2 \times 10^5$
  • $1 \leq x \leq 10^6$
  • When a query of the second type is given, there is guaranteed to be at least one ball with the integer $x$ in the bag.
  • There is at least one query of the third type.
  • All inputs are integers.

Sample Explanation 1

Initially, the bag is empty. With the first query 1 3, one ball with $3$ is put into the bag. With the second query 1 1, one ball with $1$ is put into the bag. With the third query 1 4, one ball with $4$ is put into the bag. With the fourth query 3, since there are balls with $1, 3, 4$ in the bag, output $3$. With the fifth query 2 1, one ball with $1$ is taken out of the bag. With the sixth query 3, since there are balls with $3, 4$ in the bag, output $2$. With the seventh query 1 5, one ball with $5$ is put into the bag. With the eighth query 3, since there are balls with $3, 4, 5$ in the bag, output $3$.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
8 1 3 1 1 1 4 3 2 1 3 1 5 3
样例输出
3 2 3