#C7538. Linked List Query Processing

    ID: 51420 Type: Default 1000ms 256MiB

Linked List Query Processing

Linked List Query Processing

You are given an array of n integers and q queries. The queries are of two types:

  • Type 1: Update a value at a given index. The query is in the form: 1 i x, which means update the value at position \( i \) to \( x \).
  • Type 2: Sum a subarray. The query is in the form: 2 i j, which requires calculating the sum of the subarray starting at index \( i \) and ending at index \( j \) (inclusive).

The array is 1-indexed. Process all queries in the order they are given and output the result of each sum query.

inputFormat

The input is given via standard input (stdin) in the following format:

n q
v1 v2 ... vn
query1
query2
...
queryq

Here:

  • The first line contains two integers \( n \) (the number of elements) and \( q \) (the number of queries).
  • The second line contains \( n \) integers representing the initial values of the array.
  • Each of the next \( q \) lines represents a query in one of the following forms:
    • 1 i x: Update the array at index \( i \) to value \( x \).
    • 2 i j: Output the sum of the elements from index \( i \) to \( j \) (inclusive).

outputFormat

For each query of type 2, output the corresponding sum on a new line. The results should be printed to standard output (stdout).

## sample
5 3
1 2 3 4 5
2 1 3
1 2 10
2 1 3
6

14

</p>