#P4247. [清华集训 2012] 序列操作
[清华集训 2012] 序列操作
Description
There is a sequence of length with three operations:
I a b cmeans adding to all elements in the interval .R a bmeans turning all elements in the interval into their opposites (negating them).Q a b cmeans querying the value of the sum of products over all ways to choose numbers from the interval , taken .
Input Format
The first line contains two integers , denoting the sequence length and the number of operations.
The second line contains integers, representing the sequence.
Each of the next lines contains one operation, either I a b c, R a b, or Q a b c, with meanings as described above.
Output Format
For each query, output the value of the sum of products over all ways to choose numbers from the specified interval, taken .
5 5
1 2 3 4 5
I 2 3 1
Q 2 4 2
R 1 5
I 1 3 -1
Q 1 5 1
40
19940397
Hint
Sample explanation:
After the first operation, the sequence becomes 1 3 4 4 5.
The result of the first query is .
After the R operation, it becomes -1 -3 -4 -4 -5.
After the I operation, it becomes -2 -4 -5 -4 -5.
The result of the second query is .
Constraints:
For of the testdata, . The absolute value of each element in the initial sequence is . It is guaranteed that is a valid interval. In operation I, . In operation Q, .
Translated by ChatGPT 5
京公网安备 11011102002149号