#P2861. Field Web

    ID: 16119 Type: Default 1000ms 256MiB

Field Web

Field Web

Farmer John is a true artist who creates giant works of art on his farm. Today, he plans to create a gigantic "field web" by running as many ropes as possible between pairs of non‐adjacent fence posts of his convex polygonal field. The ropes must be drawn as straight lines and must not cross one another.

However, there is one complication. Some evil aliens have created a total of G grain circles inside the field (all circles have radius R) and Farmer John does not want any rope to pass through or even touch the boundary of any grain circle. In other words, for any rope connecting two fence posts, the minimum distance from any grain circle's center to that rope must be strictly greater than R.

Given the coordinates of the fence posts (listed in convex order) and the centers of the grain circles, determine the maximum number of ropes that can be drawn. Note that the ropes correspond to diagonals of the convex polygon. The rope connecting two fence posts is considered valid only if the two posts are non‐adjacent in the original polygon and the entire line segment avoids the forbidden circles.

Constraints: 1 ≤ N ≤ 150, 0 ≤ G ≤ 100, 1 ≤ R ≤ 105. All coordinates are integers in the range [0, 106].

Note: In a convex polygon, any maximal set of non crossing ropes forms a triangulation (with exactly N-3 ropes when all diagonals are allowed). With the extra condition that some ropes may be disallowed (if they pass through or touch a grain circle), your task is to choose a subset of the allowed diagonals (ropes) that is non crossing and that has maximum size.

For a rope connecting points P and Q, and for each grain circle with center C and radius R, let the distance from C to the segment PQ be computed in the usual way. The rope is valid if and only if this distance is strictly greater than R.

inputFormat

The first line contains three integers: N, G, and R. The next N lines each contain two integers representing the coordinates of a fence post (listed in convex order). The following G lines each contain two integers representing the coordinates of a grain circle's center.

outputFormat

Output a single integer representing the maximum number of ropes (allowed, non crossing diagonals) that can be drawn.

sample

4 0 10
0 0
10 0
10 10
0 10
1

</p>