P11254 [GDKOI2023 Junior] Macaron
Description
You are given an $n \times m$ two-dimensional plane as Nana’s home. The top-left corner of the wall is $(0, 0)$, and the bottom-right corner of the wall is $(n + 1, m + 1)$.
There are $k$ 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 $r$, 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 $(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, m$, representing the size of Nana’s home.
The second line contains one integer $r^2$, representing the square of Macaron’s radius.
The third line contains two integers $x_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 $k$. In the next $k$ lines, each line contains two integers $x, y$, representing the coordinate of one piece of furniture.
Output Format
Only one integer $ans$, representing the answer.
Explanation/Hint
### Constraints
For all testdata, $0 \le k \le n \times m$, $1 \le r \le \min(\lfloor \frac{n}{2} \rfloor, \lfloor \frac{m}{2} \rfloor)$.
Among them, $30\%$ of the test points satisfy $1 \le n, m \le 100$.
The remaining $70\%$ of the test points satisfy $1 \le n, m \le 1000$.
Translated by ChatGPT 5