QOJ.ac

QOJ

Limite de temps : 2 s Limite de mémoire : 256 MB Points totaux : 100

#5818. Macaron

Statistiques

Nana's house is a 2D plane of size $n \times m$, with the top-left corner at $(0, 0)$ and the bottom-right corner at $(n+1, m+1)$. There are $k$ pieces of furniture in the house, each occupying a single point. The coordinates of each piece of furniture are given.

Macaron is a circular robotic vacuum cleaner with radius $r$. It can move in four directions: up, down, left, and right. Before and after each move, its center must be at an integer coordinate. It cannot move through furniture or outer walls; that is, its body cannot overlap with any furniture or walls (tangency is allowed). It starts with its center at $(x_s, y_s)$ and 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 integer points in the plane that its center can reach starting from its initial position.

By the way, you only need to tell the answer to Macaron, not to Nana, because Macaron does not want to worry sad Nana with these trivial matters.

Input

The first line contains two integers $n, m$, representing the size of Nana's house.

The second line contains an 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 Macaron does not overlap with any furniture at its initial position.

The fourth line contains an integer $k$, followed by $k$ lines, each containing two integers $x, y$, representing the coordinates of one piece of furniture.

Output

A single integer $ans$, representing the answer.

Constraints

For all data, $0 \le k \le n \times m$, $1 \le r \le \min(\lfloor \frac{n}{2} \rfloor, \lfloor \frac{m}{2} \rfloor)$, $1 \le x_s \le n$, $1 \le y_s \le m$.

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

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

Examples

Input 1

10 10
5
4 5
5
7 10
6 10
5 9
4 9
4 10

Output 1

29

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.