P29489 [洛谷] [COCI2016-2017#3] Meksikanac
入门
题目描述

Problem Description

Norman has a fly swatter shaped like a given $K$-sided polygon. He wants to know how many ways there are to place the fly swatter such that its vertices are within a rectangle with vertices at $(0,0)$ and $(X_p,Y_p)$, and all vertices are lattice points, ensuring that no flies are harmed.

A lattice point is defined as a point where both the x-coordinate and y-coordinate are integers.

There are $N$ flies within this rectangle, each represented as a point $(X,Y)$. A fly is considered harmed if it lies on a vertex, edge, or inside the fly swatter.

The fly swatter cannot be rotated or flipped.

Input Format

The first line contains three positive integers $X_p, Y_p, N$, which are described above.

The next $N$ lines each contain two positive integers $(X, Y)$, representing the coordinates of the $i$-th fly.

The following line contains a positive integer $K$, representing the number of vertices of the polygon.

The next $K$ lines each contain two positive integers $(X_i, Y_i)$, representing the coordinates of the vertices when the first vertex of the fly swatter is at $(X_1, Y_1). The vertices are given in sequential order.

Output Format

You need to output the number of feasible ways to place the fly swatter.

Sample Input and Output

Sample Input #1

4 5 2
1 3
3 4
4
0 0
2 0
2 2
0 2

Sample Output #1

4

Sample Input #2

5 5 3
1 4
1 3
2 2
3
4 7
6 3
7 6

Sample Output #2

3

Sample Input #3

6 7 2
2 5
4 5
8
1 4
3 3
4 1
5 3
7 4
5 5
4 7
3 5

Sample Output #3

1

Notes

Sample Explanation

Sample 1 Explanation

The possible positions for the fly swatter are as follows:

There are 4 ways.

Sample 2 Explanation

The possible positions for the fly swatter are as follows:

There are 3 ways.

Sample 3 Explanation

The possible positions for the fly swatter are as follows:

There is 1 way.

Data Size and Constraints

For 63% of the data, it is guaranteed that $1 \leq X_p, Y_p \leq 100$.

For 100% of the data, it is guaranteed that $1 \leq X_p, Y_p \leq 500, 1 \leq N \leq X_p \times Y_p, 3 \leq K \leq 10^4, 0 < X < X_p, 0 < Y < Y_p, -10^9 \leq X_i, Y_i \leq 10^9$.

Notes

This problem is translated from COCI2016-2017 CONTEST #3 T6 Meksikanac.

The explanations for Samples 1 and 2 are unofficial.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 5 2 1 3 3 4 4 0 0 2 0 2 2 0 2
样例输出
4