410814: GYM104120 D Denji

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

D. Denjitime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Denji is trying to kill the algorithm demon. To kill him, Denji must perform this task.

Initially, the demon will give Denji an empty array. Then, Denji should perform a sequence of $$$M$$$ operations.

An operation can be one of the following:

  1. Add a number to the end of the array.
  2. Delete from the array the number added in operation i.
  3. Add X to the number added in operation i.
  4. Print the number of smaller elements than the number added in operation i.

Unfortunately, Denji only knows how to use chainsaws, not computers, so he asked for your help to kill the algorithm demon.

Input

The first line of input contains an integer $$$M$$$ ($$$1$$$ $$$\leq$$$ $$$M$$$ $$$\leq$$$ $$$10^5$$$).

The following m lines describe the operations. The i-th of them begins with a number $$$type$$$ ($$$type$$$ $$$\in$$$ {1,2,3,4}), which will represent the type of the operation given.

If $$$type$$$ = 1, there will be one more integer in the line: $$$A$$$ (1 $$$\leq$$$ $$$A$$$ $$$\leq$$$ $$$10^9$$$), which correspond the operation 1.

If $$$type$$$ = 2, there will be one more integer in the line: $$$B$$$ (1 $$$\leq$$$ $$$B$$$ $$$<$$$ $$$i$$$), which correspond the operation 2. It is guaranteed that the number added in operation $$$B$$$ is still in the array.

If $$$type = 3$$$, there will be two integers more in the line: $$$B$$$, $$$A$$$ (1 $$$\leq$$$ $$$B$$$ $$$<$$$ $$$i$$$; 1 $$$\leq$$$ $$$A$$$ $$$\leq$$$ $$$10^9$$$), which correspond the operation 3. It is guaranteed that the number added in operation $$$B$$$ is still in the array.

If $$$type$$$ = 4, there will be one more integer in the line: $$$B$$$ (1 $$$\leq$$$ $$$B$$$ $$$<$$$ $$$i$$$), which correspond the operation 4. It is guaranteed that the number added in operation $$$B$$$ is still in the array.

It is guaranteed that the first operation is of type 1.

Output

For each operation 4, please print a line containing the answer.

ExamplesInput
5
1 4
1 5
1 4
4 2
4 3
Output
2
0
Input
9
1 5
1 5
1 10
4 3
2 2
4 3
3 3 7
4 3
4 1
Output
2
1
1
0

加入题单

上一题 下一题 算法标签: