#P6707. [COCI 2010/2011 #7] UPIT
[COCI 2010/2011 #7] UPIT
Background
Mirko is tired of implementing different data structures for different tasks. So, he decided to write one ultimate data structure to handle his favorite sequence of numbers.
Come and help him!
Mirko will give you his sequence, as well as a series of operations you must perform. Each query either asks for information about the sequence or modifies the existing sequence. All possible operation types are listed below.
| Query type | Description | Example |
|---|---|---|
1 A B X |
Change all elements in to | |
2 A B X |
Increase all elements in by a value: position increases by | |
3 C X |
Insert a number with value before the original position | |
4 A B |
Query the sum of values in |
Problem Description
Given a sequence , the following operations are supported.
Let the current length of the sequence be .
| Query type | Description |
|---|---|
1 A B X |
. |
2 A B X |
. |
3 C X |
, . |
4 A B |
Compute . |
Input Format
The first line contains two positive integers and , representing the initial length of the sequence and the number of operations.
The second line contains non-negative integers, representing the initial sequence.
The next lines each contain one query as described above.
Output Format
For each type operation, output one line with the answer.
5 5
1 2 3 4 5
1 5 5 0
4 4 5
4 5 5
2 1 5 1
4 1 5
4
0
25
1 7
100
3 1 17
3 2 27
3 4 37
4 1 1
4 2 2
4 3 3
4 4 4
17
27
100
37
Hint
Constraints
Let the current sequence length be .
For of the testdata: , , , , .
Notes
This problem is worth points in total.
Translated from COCI2010-2011 CONTEST #7 T6 UPIT.
Translated by ChatGPT 5