#C11886. Array Update Operations

    ID: 41251 Type: Default 1000ms 256MiB

Array Update Operations

Array Update Operations

You are given an array of n integers and q operations. There are two types of operations:

  • Single Update: The operation is given as 1 x y. This means update the element at index \(x\) to \(y\) (using 1-based indexing). That is, update \(a_x = y\).
  • Range Update: The operation is given as 2 l r k. This means add \(k\) to every element from index \(l\) to \(r\) inclusive (using 1-based indexing). Formally, for every index \(j\) such that \(l \leq j \leq r\), update \(a_j = a_j + k\).

After performing each operation sequentially, you must print the current state of the array as a space separated string. All updates are permanent and affect subsequent operations.

inputFormat

The input is read from stdin and has the following format:

N Q
a1 a2 ... aN
operation_1
operation_2
...
operation_Q

Here, \(N\) is the number of elements in the array and \(Q\) is the number of operations. Each operation is in one of the two forms described in the problem statement.

outputFormat

For each operation, output the current state of the array on a new line to stdout. Each line should have the array elements separated by a single space.

## sample
5 3
2 3 5 7 11
1 3 6
2 1 4 2
1 5 -1
2 3 6 7 11

4 5 8 9 11 4 5 8 9 -1

</p>