#P11139. [APC001] D - Array Again
[APC001] D - Array Again
Problem Description
You need to maintain a sequence that supports types of operations:
1 x y: Insert numbers into the sequence consecutively.2 x y: Delete from the sequence times consecutively. If, in some deletion, no longer exists in the sequence, ignore that deletion.3: Deduplicate the sequence. That is, for each distinct positive integer that has appeared in the sequence, if it appears more than time, keep only one in the sequence and delete all the others.4 x: Query the number of occurrences of in the sequence.
For each operation 4, output the answer.
Input Format
The first line contains an integer , which represents the number of operations.
The next lines each contain several integers, describing one operation.
Output Format
For each operation 4, output one line containing the answer.
The testdata guarantees that there is at least one operation 4.
5
1 2 10
2 2 5
4 2
3
4 2
5
1
4
1 1000000000 1000000000
1 1000000000 1000000000
1 1000000000 1000000000
4 1000000000
3000000000
20
4 95002957
2 384405322 255642125
2 384405322 174926753
2 384405322 51265222
1 384405322 311383201
4 384405322
1 384405322 5464229
4 22438767
4 17075617
1 384405322 153189933
1 230228188 148299369
1 7168162 387115701
1 384405322 154480360
1 384405322 438458686
3
1 7961090 98996809
4 153074129
1 975025351 171484003
1 384405322 650527951
4 384405322
0
311383201
0
0
0
650527952
Hint
Sample Explanation
Operation : Insert copies of .
Operation : Delete copies of . After that, the sequence contains only copies of .
Operation : Query the number of occurrences of , which is .
Operation : Deduplicate the sequence. After that, the sequence contains only one .
Operation : Query the number of occurrences of , which is .
Sample Explanation
Please note that the answer may exceed the range of int.
Constraints
For of the testdata, , .
Please note: Since there is no partial scoring in the contest where this problem comes from, you can get full score only by passing all test points; otherwise, you will get points.
Translated by ChatGPT 5