#P5358. [SDOI2019] 快速查询
[SDOI2019] 快速查询
Description
Given an integer sequence of length , whose elements are numbered in order as . Initially, all elements are zero. Then, in chronological order, a number of modifications or queries on this sequence are given. Each modification or query must be one of the following six types:
-
1 i val: Assign the given integer .
-
2 val: Add to all elements at the same time.
-
3 val: Multiply all elements by at the same time.
-
4 val: Assign all elements to at the same time.
-
5 i: Query the current value of the -th element .
-
6: Query the current sum of all elements.
Input Format
To avoid overly large input, the input file uses the following format.
The first line contains an integer , denoting the length of the sequence.
The second line contains an integer , and then the next lines each give one modification or query. The input format is the same as described above; see the sample.
We call the above modifications or queries the standard operations.
After that, an integer is given, and then the next lines each contain two positive integers and , where the index runs from to .
You need to perform a total of operations on the sequence of length that is initially all zeros.
The -th operation is the -th given standard operation ( and ).
Output Format
Output one integer, representing the total sum of all query answers.
Since the answer may be very large, you only need to output the result modulo .
Note: If the final accumulated sum is negative, you should output .
7
28
6
4 -192321079
3 418379342
1 3 189801569
3 -840249197
4 -751917965
3 649799919
1 5 -92666141
6
4 451258008
5 1
4 696880327
3 772574465
6
4 301010289
3 480168068
5 3
5 2
4 840536237
5 5
5 4
1 7 -792284106
2 604521872
3 966540578
2 -381646699
3 -939378260
2 -20129935
6
2
0 1
197 199
2816930
Hint
Subtask ( points): , , and . All appearing in the input satisfy . All and satisfy .
Subtask ( points): , , and . All appearing in the input satisfy . All and satisfy .
Translated by ChatGPT 5
京公网安备 11011102002149号