#K77137. Taco Array Query Operations
Taco Array Query Operations
Taco Array Query Operations
You are given an array of integers and a series of queries. There are two types of queries:
- Update query: 1 X Y – update the array element at index X (1-indexed) to the new value Y.
- Prefix sum query: 2 L R – calculate the sum of the elements in the array from index L to R (inclusive). That is, compute \(\sum_{i=L}^{R} B_i\).
The input consists of multiple test cases. For each test case, you are given the size of the array \(M\), the number of queries \(P\), the initial array, and the list of queries. Process the queries in the order they are given. For every prefix sum query, output the computed sum.
Your task is to implement the solution so that it reads from standard input (stdin) and writes the result of all prefix sum queries to standard output (stdout). Each result must be printed on a new line.
inputFormat
The input is read from stdin and has the following format:
T M P B1 B2 ... BM query1 query2 ... queryP
Where:
- T is the number of test cases.
- For each test case:
- M is the number of elements in the array.
- P is the number of queries.
- The next line contains \(M\) integers representing the initial array \(B\).
- Each of the next \(P\) lines represents a query which is either an update query or a prefix sum query as described above.
Note: All indices are 1-indexed.
outputFormat
For each prefix sum query, output the result (the sum) on a separate line. The output should be printed to stdout.
## sample1
5 5
1 2 3 4 5
2 1 3
1 3 10
2 2 4
1 5 15
2 1 5
6
16
32
</p>