QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 128 MB 總分: 100

#4848. Squares

统计

An unusual painter is painting an unusual picture. We can imagine his canvas as a coordinate plane. It is white at the beginning of the creation of the picture, and the painter will create the picture by repeating the following procedure $N$ times:

  • The painter chooses arbitrary integer coordinates $x$ and $y$.
  • Then, he finds the largest square with sides parallel to the coordinate axes, centered at the point $(x, y)$, such that the entire square on the existing picture is of the same color. However, the side length of the square must not be greater than the given number $D$.
  • The painter then repaints the entire square black if it was white, or white if it was black.

The images show the first example test case

Write a program that will calculate the total area of the picture painted black after the picture is finished. This area does not include black color that was later covered by white color.

Input

The first line contains two natural numbers, $N$ and $D$ ($1 \le N \le 1000$, $2 \le D \le 10^6$), the number of squares the painter will draw, and the maximum allowed side length of the square. The number $D$ will be even.

In each of the following $N$ lines, there are two integers $X$ and $Y$ ($-10^6 \le X, Y \le 10^6$), the coordinates of the center of each square.

Output

In the first and only line of output, print the total area of the picture painted black.

Examples

Input 1

4 10
8 12
8 9
8 19
8 14

Output 1

64

Input 2

2 1000000
0 0
0 0

Output 2

0

Input 3

6 200
0 0
-100 -100
-100 105
0 101
100 105
0 0

Output 3

204

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.