#P8259. [CTS2022] 回

[CTS2022] 回

Problem Description

You need to maintain integer lattice points on a plane. Each point initially has weight 00. There are mm operations in total.

Update operation: given x,y,d,wx, y, d, w, increase the weight of every integer point (X,Y)(X, Y) satisfying ∣X−x∣<d|X-x|<d and ∣Y−y∣<d|Y-y|<d by w⋅(d−max⁡(∣X−x∣,∣Y−y∣))w\cdot(d-\max(|X-x|,|Y-y|)).

Query operation: given x1,x2,y1,y2x_1, x_2, y_1, y_2, query the sum of weights of all integer points (X,Y)(X, Y) satisfying x1≤X≤x2x_1\le X\le x_2 and y1≤Y≤y2y_1\le Y\le y_2. The answer is taken modulo 2302^{30}.

Input Format

Read input from standard input.

The first line contains an integer mm. The next mm 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 23%23\% of the testdata, 1≤m≤1031\le m\le 10^3.

For 31%31\% of the testdata, 1≤m≤2×1041\le m\le 2\times 10^4.

For 39%39\% of the testdata, 1≤m≤4×1041\le m\le 4\times 10^4.

For 47%47\% of the testdata, 1≤m≤6×1041\le m\le 6\times 10^4.

For 55%55\% of the testdata, 1≤m≤8×1041\le m\le 8\times 10^4.

For another 15%15\% of the testdata, for any query operation, there does not exist an update operation that occurs after this query operation.

For another 10%10\% of the testdata, x2−x1≤5x_2-x_1\le 5, y2−y1≤5y_2-y_1\le 5, and d≤5d\le 5.

For another 10%10\% of the testdata, d≤5d\le 5.

For 100%100\% of the testdata, 1≤m≤1051\le m\le 10^5, 1≤x1≤x2≤1081\le x_1\le x_2\le {10}^8, 1≤y1≤y2≤1081\le y_1\le y_2\le {10}^8, and 1≤x,y,d,w≤1081\le x, y, d, w\le {10}^8.

Each category of testdata forms a subtask.

Translated by ChatGPT 5