#P6749. 『MdOI R3』Yoshino
『MdOI R3』Yoshino
Description
Yoshino gives you a sequence of length , where the -th term is .
Now Yoshino will perform operations on the sequence.
There are two types of operations:
-
: Yoshino changes the numbers with indices in the interval into an arithmetic progression starting from with common difference .
-
: Yoshino needs to query the number of inversion pairs in the entire sequence. An inversion pair is a pair such that and .
Input Format
The first line contains two integers .
The second line contains integers; the -th one is .
The next lines each describe an operation, with the meaning as stated above.
Output Format
For each query, output one integer per line as the answer.
3 3
3 2 1
2
1 1 3 1
2
3
0
Hint
[Sample Explanation]
The first operation is a query. At this time there are three inversion pairs: , so the answer is .
After the second operation (the modification), the sequence becomes .
The third operation is a query. At this time there are no inversion pairs in the sequence, so the answer is .
You can get more samples here.
[Constraints]
This problem uses bundled testdata.
| Subtask ID | Special Condition | Score | Time Limit | |
|---|---|---|---|---|
| None | ||||
| The modification length is | ||||
| The maximum value in the sequence never exceeds | ||||
| The odd-numbered operation is guaranteed to be | ||||
| No special restrictions |
For all testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号