#P8659. [蓝桥杯 2017 国 A] 数组操作
[蓝桥杯 2017 国 A] 数组操作
Description
Given an array of length , indexed from to , you need to maintain operations.
There are three types of operations, with input formats as follows:
1 L R d: Add to all positions in the array with indices from to . That is, for , perform .
2 L1 R1 L2 R2: Assign the values of positions to to positions to . It is guaranteed that .
In other words, first perform for , then perform for , where is a temporary array.
3 L R: Query the sum of positions in the array with indices from to , i.e., compute .
Input Format
Read input from standard input.
The first line contains an integer Case, indicating the test point ID. When Case is , it means this test point is the sample.
The second line contains two integers . It is guaranteed that .
The third line contains integers , representing the initial values of the array. It is guaranteed that .
The next lines each describe an operation, in the format shown in the problem description.
For every number mentioned in the operations, it holds that , , , , and .
Output Format
For each operation of type , output one line with one number, representing the sum result.
0
5 6
1 2 3 4 5
2 1 3 3 5
3 3 5
1 2 4 2
3 3 5
2 1 3 3 5
3 1 5
14
18
29
Hint
| Test point | , | Other constraints |
|---|---|---|
| 1, 2 | None. | |
| 3, 4 | No operation of type . | |
| 5, 6, 7 | is even, and all type operations satisfy , , , . | |
| 8, 9, 10 | None. |
For of the testdata, , and .
Translated by ChatGPT 5
京公网安备 11011102002149号