#P11254. [GDKOI2023 普及组] Macaron

[GDKOI2023 普及组] Macaron

Problem Description

You are given an n×mn \times m two-dimensional plane as Nana’s home. The top-left corner of the wall is (0,0)(0, 0), and the bottom-right corner of the wall is (n+1,m+1)(n + 1, m + 1).

There are kk pieces of furniture in the home. Each piece of furniture occupies exactly one lattice point, and the problem will give the coordinate of each piece of furniture.

Macaron is a cleaning robot. It is a circle with radius rr, and it can move in four directions: up, down, left, and right. Before and after each move, its center must stay on lattice points. It cannot pass through furniture or the outer walls while cleaning, meaning its body cannot overlap with any furniture or wall (tangency is allowed). Its initial center position is (xs,ys)(x_s, y_s). Starting from there, it will clean the area it can reach.

Macaron wants to know how large an area it can clean. You only need to tell Macaron the number of lattice points in the plane that its center can reach after it starts.

Also, you only need to tell the answer to Macaron. There is no need to tell Nana, because Macaron does not want sad Nana to be bothered by these trivial matters.

Input Format

The first line contains two integers n,mn, m, representing the size of Nana’s home.

The second line contains one integer r2r^2, representing the square of Macaron’s radius.

The third line contains two integers xs,ysx_s, y_s, representing Macaron’s starting position. It is guaranteed that at its initial position, Macaron does not overlap with any furniture.

The fourth line contains one integer kk. In the next kk lines, each line contains two integers x,yx, y, representing the coordinate of one piece of furniture.

Output Format

Only one integer ansans, representing the answer.

10 10
5
4 5
5
7 10
6 10
5 9
4 9
4 10
29
见/example/macaron/下的 macaron1.in
见/example/macaron/下的 macaron1.out

Hint

Constraints

For all testdata, 0kn×m0 \le k \le n \times m, $1 \le r \le \min(\lfloor \frac{n}{2} \rfloor, \lfloor \frac{m}{2} \rfloor)$.

Among them, 30%30\% of the test points satisfy 1n,m1001 \le n, m \le 100.

The remaining 70%70\% of the test points satisfy 1n,m10001 \le n, m \le 1000.

Translated by ChatGPT 5