Horse tied outside the castle
Time limit0.1sMemory limit16 MB
Given a convex polygon and an exterior point with rope length L, compute the area reachable when the rope bends around polygon vertices and the two wrapping directions do not overlap.
- Level
Hard8 of 10
- Topics
- Geometry, Math, Implementation
- Solved
- No attempts yet
Problem
The castle wall is a convex polygon with vertices. A tree stands outside the wall at the integer coordinates , and a knight ties his horse to that tree with a rope of length .
The horse cannot enter the castle, and the rope cannot pass through the wall. When the rope catches on a corner of the wall it bends at that vertex, so the horse walks around the castle as long as the rope reaches.
The horse reaches a point outside the castle exactly when the shortest path from the tree to that avoids the interior of the castle has length at most .
Compute the area of the region the horse reaches.
Input
The first line contains the coordinates of the tree, and , and the length of the rope , separated by spaces. The second line contains the number of vertices . Each of the next lines contains two integers and , the vertices of the polygon in clockwise order.
Output
Print the area of the region the horse reaches, rounded to exactly five digits after the decimal point. For an area of , print 3.14159.
Constraints
- All coordinates are integers.
- The polygon is convex, and no three vertices lie on one line.
- The tree is outside the castle. It is never inside the wall or on it.
- Let be the perimeter of the convex hull of the vertices together with the tree. Then , so the region the horse reaches by going around the castle to the left never overlaps the region it reaches by going around to the right.