#P2023. [AHOI2009] 维护序列
[AHOI2009] 维护序列
Description
There is a sequence of length , , with the following three types of operations:
- Format
1 t g c: set all with to . - Format
2 t g c: set all with to . - Format
3 t g: query the sum of all with . Since the answer may be large, you only need to output this sum modulo .
Input Format
The first line contains two integers and .
The second line contains non-negative integers, representing the sequence .
The third line contains an integer , the total number of operations.
From the fourth line on, each line describes one operation. In the same line, adjacent numbers are separated by a single space, and there are no extra spaces at the beginning or end.
Output Format
For each operation of type 3, in the order they appear in the input, output one integer per line representing the query result.
7 43
1 2 3 4 5 6 7
5
1 2 5 5
3 2 4
2 3 7 9
3 1 3
3 4 7
2
35
8
Hint
Explanation for Sample Input/Output 1
- Initially, the sequence is .
- After the 1st operation, the sequence becomes .
- For the 2nd operation, the sum is , and .
- After the 3rd operation, the sequence becomes .
- For the 4th operation, the sum is , and .
- For the 5th operation, the sum is , and .
Constraints
The testdata scale is as follows:
| Data point ID | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9,10 |
|---|---|---|---|---|---|---|---|---|---|
For all test points, it is guaranteed that , .
Translated by ChatGPT 5
京公网安备 11011102002149号