QOJ.ac

QOJ

Time Limit: 10 s Memory Limit: 512 MB Total points: 100

#3155. Rampart

Statistics

Professor JOI, a historian, is researching the long-lost IOI Kingdom. According to past surveys, the IOI Kingdom was in the shape of a rectangle divided into $H$ rows and $W$ columns of cells. The capital of the IOI Kingdom was surrounded by a rampart for defense.

The rampart surrounding the capital of the IOI Kingdom has a specific shape. A value called the size is defined for the rampart. A rampart of size $s$ ($s \ge 3$) is defined as an $s \times s$ square region excluding the $(s - 2) \times (s - 2)$ square region in its interior.

According to the survey, the size of the rampart surrounding the capital was at least $L$. Also, it is known that there were some cells in the IOI Kingdom where no rampart existed.

For further research, Professor JOI wants to know how many possible ramparts could have existed.

Task

Given the size of the IOI Kingdom, the minimum size of the rampart, and information about the cells where it is known that no rampart existed, write a program to calculate the number of possible ramparts.

Input

Read the following data from standard input:

  • The first line contains four space-separated integers $H, W, L, P$. This indicates that the IOI Kingdom is a rectangle of $H$ rows and $W$ columns, the size of the rampart is at least $L$, and there are $P$ cells where it is known that no rampart existed.
  • The $i$-th line of the following $P$ lines ($1 \le i \le P$) contains two space-separated integers $A_i, B_i$. This indicates that it is known that no rampart existed in the cell at the $A_i$-th row from the top and the $B_i$-th column from the left of the IOI Kingdom.

Output

Output a single integer on one line representing the number of possible ramparts.

Constraints

All input data satisfies the following conditions:

  • $1 \le H \le 4000$.
  • $1 \le W \le 4000$.
  • $3 \le L \le H$ and $3 \le L \le W$.
  • $0 \le P \le 100\,000$.
  • $1 \le A_i \le H$ ($1 \le i \le P$).
  • $1 \le B_i \le W$ ($1 \le i \le P$).
  • $(A_i, B_i) \neq (A_j, B_j)$ ($1 \le i < j \le P$).

Subtasks

Subtask 1 [4 points]

  • $H \le 500$.
  • $W \le 500$.

Subtask 2 [16 points]

  • $0 \le P \le 10$.

Subtask 3 [80 points]

  • No additional constraints.

Examples

Input 1

5 5 3 2
2 2
4 3

Output 1

4

Note

In this input example, there are 4 possible ramparts. The cells marked with $\times$ are the cells where it is known that no rampart existed.

Input 2

7 8 4 3
2 2
3 7
6 5

Output 2

13

Input 3

4000 4000 1234 4
1161 3028
596 1892
3731 2606
702 1530

Output 3

7050792912

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.