luogu#P5009. [yLOI2018] 不老梦
[yLOI2018] 不老梦
Background
Among tens of thousands, by great luck we meet; in an instant, everything becomes clear and bright.
It becomes my courage and fear that make me unstoppable, splitting mountains and seas, falling into the sky.
— Yin Lin, Ageless Dream.
The original name of this problem was Poisonous Block Decomposition Problem.
Problem Description
Fusu really likes writing tricky block decomposition problems while listening to Chinese-style songs. So this statement is intentionally designed to make block decomposition hard to use.
You are given a sequence. Each number in the sequence has three parameters . This sequence has a very magical time-related property: every time moment passes, the value of the -th number increases by .
Now Fusu will ask you some queries and perform some modifications on the sequence. Each operation is one of the following:
- Query: at time , what is the sum of over the interval .
- Modify : at time , add an integer to all in the interval .
- Modify : at time , add an integer to all in the interval .
- Modify : at time , add an integer to all in the interval .
The initial time is defined as time .
Input Format
Each test point has exactly one set of testdata.
The first line contains two integers separated by spaces, representing the length of the sequence and the number of operations .
The next lines each contain integers separated by spaces. On the -th line, the integers represent the three parameters at position .
The next lines describe the operations. The first number of each line is , representing the type of operation.
- For , it means one query on the sequence. After there are three integers separated by spaces, meaning: query the sum of in interval at time .
- For , it means one modification to the values. After there are four integers separated by spaces, meaning: at time , add to all in interval .
- For , it means one modification to the values. After there are four integers separated by spaces, meaning: at time , add to all in interval .
- For , it means one modification to the values. After there are four integers separated by spaces, meaning: at time , add to all in interval .
The data guarantees that the parameter is strictly increasing, and there will not be more than one query or modification at the same time moment.
Output Format
For each query operation, output one integer per line, representing the answer modulo .
5 5
1 2 3
4 5 6
7 8 9
10 11 12
13 14 15
2 1 1 3 2
1 3 2 3
3 4 1 4 -3
4 5 1 3 -5
1 6 1 5
377
2708
Hint
Sample Input/Output 1 Explanation

Constraints
This problem has test points, with unequal weights. For each test point, the value of is given in the table below.
| Test Point ID | Test Point ID | ||
|---|---|---|---|
Scores for test points:
- For test points to , each test point is worth points.
- For test points to , each test point is worth points.
Values of for test points:
- For test point , .
- For test point , .
- For test points to , .
Special properties of test points:
- For all test points where the last digit of is , the following property holds: the time moments used by operations start from and increase by each time.
- For all test points where the last digit of is , the following property holds: all modification operations only modify , and the modification interval satisfies .
- For all test points where the last digit of is , the following property holds: all modification operations only modify .
- For all test points where the last digit of is , the following property holds: no modification operation modifies , and for modifications to , it holds that .
- For all test points where the last digit of is , the following property holds: there are no modification operations.
For all test points, it is guaranteed that , , all given numbers are within the range of 32-bit signed integers, is positive, and is given in strictly increasing order.
Hint
- Please pay attention to the impact of input reading on program efficiency.
- Please pay attention to the impact of constant factors on program efficiency.
- The last digit of can help you quickly determine the special properties of a test point.
- If your answer is negative, please take it modulo into a non-negative number before outputting it.
Translated by ChatGPT 5