P28754 [洛谷] [SHOI2008] Safe航线
提高+
题目描述

Problem Description

When designing a flight route, safety is a critical issue. Firstly, utmost measures should be taken to ensure that no accidents occur during the flight. However, it is also essential to prepare for the worst-case scenario, ensuring that passengers have the highest possible chance of survival if an accident does happen.

When a plane is forced to land at sea, the nearest land becomes a crucial factor. The most dangerous point on the route is where the distance to the nearest land is the greatest, which we call the "isolated point" of the route. The distance from the isolated point to the nearest land is referred to as the "isolated distance." As a senior consultant for the airline, your first task is to identify the isolated point of a route and calculate its isolated distance.

To simplify the problem, we consider the map as a two-dimensional plane, where land is approximated by polygons, and the flight route is represented by a polyline. The starting and ending points of the route are on land, but the intermediate turning points may be over the sea (as shown in the figure below, the squares mark the isolated points).

Input Format

The first line of input contains two integers C and N (1 ≤ C ≤ 20, 2 ≤ N ≤ 20), representing the number of landmasses and the number of turning points in the route, respectively.

The next N lines each contain two integers x and y, representing the coordinates of a turning point in the route, with the first point being the starting point and the last point being the ending point.

The subsequent input describes the C landmasses. Each landmass description begins with a positive integer M (M ≤ 30), indicating the number of vertices of the polygon. The following M lines each contain two integers x and y, representing the coordinates of a vertex of the polygon. We guarantee that these vertices are given in either clockwise or counterclockwise order to form a closed polygon without any intersecting edges. Additionally, we ensure that no two landmasses intersect.

All coordinates in the input will be within the range of -10,000 to 10,000.

Output Format

Output a floating-point number representing the isolated distance of the route, rounded to two decimal places.

Sample Input and Output

Sample Input #1

1 2
-9 -6
5 1
3
0 16
-16 -12
17 -6

Sample Output #1

0.00

Sample Input #2

2 3
12 4
16 17
3 9
4
1 0
4 19
19 14
6 12
3
10 10
5 3
18 2

Sample Output #2

2.94

Notes

For 50% of the test cases, 1 ≤ C ≤ 2, 2 ≤ N ≤ 5;

For 100% of the test cases, 1 ≤ C ≤ 20, 2 ≤ N ≤ 20.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
1 2 -9 -6 5 1 3 0 16 -16 -12 17 -6
样例输出
0.00