#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 Xx<d|X-x|<d and Yy<d|Y-y|<d by w(dmax(Xx,Yy))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 x1Xx2x_1\le X\le x_2 and y1Yy2y_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, 1m1031\le m\le 10^3.

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

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

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

For 55%55\% of the testdata, 1m8×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, x2x15x_2-x_1\le 5, y2y15y_2-y_1\le 5, and d5d\le 5.

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

For 100%100\% of the testdata, 1m1051\le m\le 10^5, 1x1x21081\le x_1\le x_2\le {10}^8, 1y1y21081\le y_1\le y_2\le {10}^8, and 1x,y,d,w1081\le x, y, d, w\le {10}^8.

Each category of testdata forms a subtask.

Translated by ChatGPT 5