#K61402. Array Range Operations
Array Range Operations
Array Range Operations
You are given an array of n integers and a sequence of q operations. The operations are defined as follows:
- 1 l r x: For all indices i such that l ≤ i ≤ r, add x to a[i].
- 2 l r x: For all indices i such that l ≤ i ≤ r, multiply a[i] by x.
- 3 i: Output the value of a[i].
Note that the array is 1-indexed. The constraints are given by the following inequalities in \(\LaTeX\) format: \(1 \le n \le 10^5\), \(1 \le q \le 10^5\), and \(1 \le a_i, x \le 10^9\).
Your task is to update the array according to the operations and for every query operation (type 3), print the current value of the specified element.
inputFormat
The input is provided via standard input (stdin) and follows the format below:
n q a1 a2 ... an op1 op2 ... opq
The first line contains two space-separated integers representing the number of elements in the array (n) and the number of operations (q). The second line contains n space-separated integers representing the initial array. The next q lines each describe an operation in one of the three formats mentioned above.
outputFormat
For each operation of type 3, output the result of the query on a new line on standard output (stdout).
## sample5 6
10 20 30 40 50
1 1 3 5
2 2 4 2
3 3
3 5
1 4 5 10
3 4
70
50
90
</p>