#C9474. Sequence Query Processing

    ID: 53571 Type: Default 1000ms 256MiB

Sequence Query Processing

Sequence Query Processing

You are given a sequence of (n) integers and (q) queries. There are two types of queries:

  1. Sum Query: A query of the form (1\ l\ r) asks you to compute the sum of the subsequence from index (l) to (r) (1-indexed), i.e., [ \text{Sum} = \sum_{j=l}^{r} a_j ]

  2. Update Query: A query of the form (2\ i\ x) updates the element at index (i) of the sequence to the value (x).

Your task is to process all the queries in the order given, output the result for each sum query, and finally output the updated sequence. All indexing is 1-based.

inputFormat

The first line contains two integers (n) and (q) separated by a space, representing the number of elements in the sequence and the number of queries respectively.

The second line contains (n) integers separated by spaces, representing the initial sequence.

Each of the following (q) lines contains three integers describing a query. For a query of type 1, the line is in the format: (1\ l\ r). For a query of type 2, the line is in the format: (2\ i\ x).

outputFormat

For each sum query (type 1), output the computed sum in a new line. After processing all queries, output the final updated sequence in one line with each number separated by a space.## sample

5 5
1 2 3 4 5
1 1 3
2 3 10
1 2 4
2 5 7
1 1 5
6

16 24 1 2 10 4 7

</p>