Problem Description
The ant is on a board shaped like a convex polygon. It moves straight in the direction it is facing, but does not know which direction that is. If it reaches the edge of the board, it will fall off. Given the position of the ant and the positions of the vertices that make up the convex polygon of the board, determine the shortest distance it can travel before falling off the board. All positions are given in 2D coordinates.
Input
The first line contains two integers and , representing the coordinates of the ant (, ).
The second line contains an integer , representing the number of vertices of the polygon ().
The next lines contain integers and (), representing the coordinates of the vertices of the polygon, given in counterclockwise order.
All input values are integers. The point is guaranteed to be strictly inside the polygon (not on the boundary), and the polygon is guaranteed to be convex.
Output
Output the shortest distance that the ant can travel before falling off the board, on a single line. The output will be accepted if the absolute error or relative error does not exceed .
Scoring System
| Subtasks | Additional Constraints | Points | Required Subtasks |
|---|---|---|---|
| 0 | Example | 0 | — |
| 1 | 25 | — | |
| 2 | , guaranteed that the sides are parallel to the coordinate axes | 15 |
Examples
0 0 4 100 100 -100 100 -100 -100 100 -100
100
10 10 3 0 100 -100 -100 100 -100
31.3049516850
34 6 7 -43 -65 -23 -99 54 -68 65 92 16 83 -18 43 -39 2
25.0284205314