This is another simple range query problem where you will perform some updates and answer some queries. Let's take an array of length . Initially, for each in the range .
You will have to perform operations on this array. There will be two types of operations:
In the first line of input, there will be two integers and (, ) which are the length of the array and number of operations to perform respectively.
Next Q lines will contain the description of the operations to perform in the format or (, ).
For each operation of the format , print the answer of the query in a single line.
10 5 2 1 5 1 4 8 10 2 2 7 1 1 10 1 2 1 10
15 -13 -5
Login to submit
If we ignore input constraints, this is a classic segment tree problem. We need Nlog(N) space and ru...