#P4286. Lonely Distance

    ID: 17532 Type: Default 1000ms 256MiB

Lonely Distance

Lonely Distance

In route planning, safety is of paramount importance. In an emergency landing at sea, the closest land is the key for survival. The most dangerous point of a flight path is the point that is farthest from any land – we call such a point the lonely point and its distance to the nearest land the lonely distance.

For simplicity, we model the map as a two‐dimensional plane. The land is approximated by a polygon and the flight route is represented by a polyline. The start and end of the flight path are on the land (i.e. on the polygon boundary), but the intermediate turning points may be over the sea.

Your task as a senior consultant is to determine the lonely distance of a given flight route. In other words, you need to find a point on the flight route whose minimum distance to the polygon (land) is maximized, and report that distance.

The distance from a point to the land is defined as the minimum Euclidean distance from that point to any point on the boundary of the polygon. If the point is on or inside the polygon, the distance is 0.

Note: If there are formulas, they should be written in \(\LaTeX\) format. For example, the distance between two points \(P_1(x_1,y_1)\) and \(P_2(x_2,y_2)\) is given by \[ d(P_1,P_2)=\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}. \]

inputFormat

The first line contains two integers (n) and (m) ((n \ge 2), (m \ge 3)), representing the number of vertices in the flight route and the number of vertices of the polygon (land) respectively. The next (n) lines each contain two real numbers (x) and (y), representing the coordinates of the flight route in order. The following (m) lines each contain two real numbers (x) and (y), representing the vertices of the polygon in order (either clockwise or counterclockwise). It is guaranteed that the first and last points of the flight route lie on the boundary of the polygon.

outputFormat

Output a single line containing a real number, the lonely distance of the flight route, rounded and printed to 6 decimal places.

sample

3 4
0 0
5 5
10 0
0 0
0 10
10 10
10 0
0.000000