#P5494. 【模板】线段树分裂
【模板】线段树分裂
Description
Given a multiset (ID ), it supports the following operations:
0 p x y: Move all values in multiset that are greater than or equal to and less than or equal to into a new multiset (the new multiset ID starts from and is the previous newly created multiset ID plus ).
1 p t: Put all numbers in multiset into multiset , and clear multiset (the testdata guarantees that multiset will not appear in subsequent operations).
2 p x q: Add copies of the number into multiset .
3 p x y: Query the number of values in multiset that are greater than or equal to and less than or equal to .
4 p k: Query the -th smallest number in multiset . If it does not exist, output -1.
Input Format
The first line contains two integers , meaning the numbers in the multiset are in the range , and there are operations.
The next line contains integers, representing the number of occurrences of each number in .
The next lines each contain several integers. The first integer is the operation ID , as described in the Description.
Output Format
Output the answer for each query operation in order.
5 12
0 0 0 0 0
2 1 1 1
2 1 1 2
2 1 1 3
3 1 1 3
4 1 2
2 1 1 4
2 1 1 5
0 1 2 4
2 2 1 4
3 2 2 4
1 1 2
4 1 3
3
2
4
3
Hint
For of the testdata, , .
For of the testdata, , . The testdata is guaranteed to be valid.
If you do not use long long, you will regret it.
Statement by
std by
Tested by
Testdata by
Translated by ChatGPT 5
京公网安备 11011102002149号