QOJ.ac

QOJ

时间限制: 10 s 内存限制: 512 MB 总分: 100 难度: [显示]

#4407. Return

统计

You need to maintain a set of integer points on a plane, each initially having a point weight of $0$. There are $m$ operations in total.

Update operation: Given $x, y, d, w$, increase the weight of every integer point $(X, Y)$ satisfying $|X-x| < d$ and $|Y-y| < d$ by $w \cdot (d - \max(|X-x|, |Y-y|))$.

Query operation: Given $x_1, x_2, y_1, y_2$, calculate the sum of weights of all integer points $(X, Y)$ satisfying $x_1 \le X \le x_2$ and $y_1 \le Y \le y_2$. The answer should be taken modulo $2^{30}$.

Input

Read data from standard input.

The first line contains an integer $m$. The next $m$ lines each describe an operation.

An update operation is represented as 1 x y d w.

A query operation is represented as 2 x1 x2 y1 y2.

Output

Output to standard output.

For each query operation, output a single line containing an integer representing the answer modulo $2^{30}$.

Examples

Input 1

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

Output 1

46
21

Subtasks

For $23\%$ of the data, $1 \le m \le 10^3$.

For $31\%$ of the data, $1 \le m \le 2 \times 10^4$.

For $39\%$ of the data, $1 \le m \le 4 \times 10^4$.

For $47\%$ of the data, $1 \le m \le 6 \times 10^4$.

For $55\%$ of the data, $1 \le m \le 8 \times 10^4$.

For another $15\%$ of the data, for any query operation, there is no update operation that occurs after that query operation.

For another $10\%$ of the data, $x_2 - x_1 \le 5$, $y_2 - y_1 \le 5$, and $d \le 5$.

For another $10\%$ of the data, $d \le 5$.

For $100\%$ of the data, $1 \le m \le 10^5$, $1 \le x_1 \le x_2 \le 10^8$, $1 \le y_1 \le y_2 \le 10^8$, and $1 \le x, y, d, w \le 10^8$.

Each category of data constitutes a subtask.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.