#P3368. 【模板】树状数组 2
【模板】树状数组 2
Description
As stated, given a sequence, you need to perform the following two operations:
- Add to every number in a given interval.
- Query the value of a specific element.
Input Format
The first line contains two integers and , representing the number of elements in the sequence and the total number of operations.
The second line contains space-separated integers, where the -th number is the initial value of the -th element of the sequence.
Each of the next lines contains or integers describing an operation, as follows:
Operation 1: Format: 1 x y k Meaning: add to every number in the interval .
Operation 2: Format: 2 x Meaning: output the value of the -th number.
Output Format
Output several lines of integers, which are the results of all type 2 operations.
5 5
1 5 4 2 3
1 2 4 2
2 3
1 1 5 -1
1 3 5 7
2 4
6
10
Hint
Explanation for Sample 1:

Therefore, the outputs are and .
Constraints
For of the testdata: , .
For of the testdata: , .
For of the testdata: , . It is guaranteed that at any time, the absolute value of any element in the sequence does not exceed .
Translated by ChatGPT 5
京公网安备 11011102002149号