Spiderweb
Time limit2sMemory limit128 MB
Given a convex polygon's vertices and circular puddles, find the maximum number of non-crossing diagonals that avoid all puddles.
- Level
Hard8 of 10
- Topics
- Dynamic programming, Geometry, Intervals, Math
- Solved
- No attempts yet
Problem
Dongju wants to create a large spiderweb-shaped artwork in a field.
The N pillars are placed as the vertices of a convex polygon. Dongju may connect two pillars with a rope only if all of the following conditions are satisfied.
- Two adjacent pillars of the polygon cannot be connected.
- No two ropes may cross. Ropes that meet at the same pillar are allowed.
- The field contains G circular puddles, each with radius R. A rope must not pass through the interior or boundary of any puddle.
Find the maximum number of ropes that can be connected while satisfying all conditions.
Input
The first line contains the number of pillars N (1 ≤ N ≤ 150), the number of puddles G (0 ≤ G ≤ 100), and the puddle radius R (1 ≤ R ≤ 100,000).
Each of the next N lines contains the coordinates x and y of one pillar. Each of the following G lines contains the coordinates x and y of the center of one puddle.
All coordinates are integers between 0 and 1,000,000 inclusive, and all coordinate points appearing in the input are distinct. The given pillars are the vertices of one convex polygon.
Output
Print the maximum number of ropes that can be connected.