#P8259. [CTS2022] 回
[CTS2022] 回
Problem Description
You need to maintain integer lattice points on a plane. Each point initially has weight . There are operations in total.
Update operation: given , increase the weight of every integer point satisfying and by .
Query operation: given , query the sum of weights of all integer points satisfying and . The answer is taken modulo .
Input Format
Read input from standard input.
The first line contains an integer . The next lines each describe an operation.
An update operation is written as 1 x y d w.
A query operation is written as 2 x1 x2 y1 y2.
Output Format
Write output to standard output.
For each query operation, output one line containing an integer, which is the answer after taking modulo.
5
1 3 4 5 1
2 1 4 3 5
1 2 4 2 2
2 4 5 3 5
1 4 4 4 8
46
21
Hint
For of the testdata, .
For of the testdata, .
For of the testdata, .
For of the testdata, .
For of the testdata, .
For another of the testdata, for any query operation, there does not exist an update operation that occurs after this query operation.
For another of the testdata, , , and .
For another of the testdata, .
For of the testdata, , , , and .
Each category of testdata forms a subtask.
Translated by ChatGPT 5