-->
当前位置:首页 > 题库

PROGRAMMING:It's just interval 3

Luz5年前 (2021-05-10)题库463
Keven now has a simple problem. He thinks it is very difficult, so he wants to test you.
The main idea of the title is as follows:
You have a sequence of N numbers (n < 200000), which indicates the length of the sequence (the subscript of the sequence starts from 1).
You need to support three operations:
1. Ask the sum of elements between intervals [l, R]
2. Operate on the interval [l, R], that is to say, you take out all the numbers in the interval, and then put the numbers less than or equal to X on the left in order, and the numbers greater than x on the right in order. Connect these numbers and put them back into the sequence.
For example, if x = 3, the number in your interval is 1,5,3,2,4, then the number in the interval becomes 1,3,2,5,4 after the operation.
3. Operate on the interval [l, R]. That is to say, you take out all the numbers in the interval, and then put the numbers greater than x on the left in order, and the numbers less than or equal to X on the right in order. Connect these numbers and put them back into the sequence.
For example, if x = 3, the number in your interval is 1,5,3,2,4, then the number in the interval becomes 5,4,1,3,2 after the operation.
###Input format:
The first three integers $$n, Q, x $$($$1 < = n, Q < = 2 * 10 ^ 5, \ \ 0 < = x < = 10 ^ 9 $$) represent the number of elements and the number of queries.
Next line $$n $$integers $$a_ 1, a_ 2, ... \ , an$$($$1 <= ai <= 10^9$$)
Next, in line Q, three positive integers, $$p, l, R $$($$1 < = P < = 3 $$), and $$1 < = l < = R < = n $$denote the operation type and interval.
###Output format:
For each of the first operations, output a line that represents the corresponding answer.
###Input example:
```in
5 2 3
1 5 3 2 4
2 1 5
1 1 4
```
###Output example:
```out
eleven
```
###Tips:
After the operation '2 1 5', the sequence changes to '1 3 2 5 4', so the answer to the operation '1 1 4' is' 1 + 3 + 2 + 5 = 11 '.







answer:If there is no answer, please comment