#P9444. [ICPC2021 WF] Islands from the Sky

[ICPC2021 WF] Islands from the Sky

题目描述

You might never have heard of the island group of Iceepeecee, but that suits their inhabitants just fine. Located in a remote part of the South Pacific, they are truly off the beaten track, without any regular air or sea traffic, and they have remained a tropical paradise with unspoiled local fauna and flora.

Being off the map is great when you don't want to be overrun by hordes of tourists, but not so ideal when you actually do need a map for some reason. One such reason came up recently: Iceepeecee's central government needs an exact map of the islands to apportion government funds. Even tropical paradises need money, so Iceepeecee needs a map!

The easiest way to create a map would be an aerial survey. After dismissing chartering planes as too expensive, building an air balloon as too dangerous, and fitting carrier pigeons with cameras as too cruel to animals, they had a brilliant idea. Even with its remote location, there are still plenty of commercial airplanes crossing the skies above Iceepeecee. What if one mounted cameras on flights that are already scheduled to fly anyway? That would be a cheap solution to the problem!

Iceepeecee's plan is to install line-scan cameras on the planes. These cameras point straight downwards and collect images one line segment at a time, orthogonal to the flight path. The photographed line segment will be determined by the altitude that the plane is flying at, and the camera's aperture angle θ\theta (see Figure F.1). Greater angles θ\theta mean that the camera can see more, but also that the camera is more expensive.

Moreover, Iceepeecee wants to make sure that each island is observed in its entirety by at least one flight. That means it is not sufficient that an island is only partially photographed by multiple flights, even if the combination of the photographs covers the whole island.

Figure F.1: A view of the plane, shown head-on. Its camera points downward and can see the part of the ground underneath the plane that is shown in green. How much is visible depends on the aperture angle θ\theta.

Flight paths follow straight line segments in three-dimensional space, that is, (x1,y1,z1x_1, y_1, z_1) - (x2,y2,z2x_2, y_2, z_2) (see Figure F.2), where the zz-coordinates give the altitude of the plane. Photographs are taken only along these line segments.

Given the location of their islands and flights, Iceepeecee wants to find the smallest aperture angle θ\theta that allows for a successful survey. Can you help?

Figure F.2: Three islands (shown in black) and two flight paths (red and green). Altitudes are not shown. The shaded areas represent the ground visible on the two flight paths for an optimally chosen θ\theta. This corresponds to the first sample input.Three islands (shown in black) and two flight paths (red and green). Altitudes are not shown. The shaded areas represent the ground visible on the two flight paths for an optimally chosen θ\theta. This corresponds to the first sample input.

输入格式

The input describes a set of islands and flight paths. It starts with a line containing two integers nn and mm, the number nn of islands, and the number mm of flight paths, respectively (1n,m1001 \leq n,m \leq 100). This is followed by descriptions of the nn islands. Each island description starts with a line containing a single integer nin_i, the number of vertices of the polygon describing the ithi^{th} island (3ni1003 \leq n_i \leq 100). It is followed by nin_i lines, each containing two integers xijx_{ij}, yijy_{ij} (xij,yij106|x_{ij}|, |y_{ij}| \leq 10^6), specifying the vertices for the ithi^{th} island in counterclockwise order. Each island's polygon is simple, that is, its vertices are distinct and no two edges of the polygon intersect or touch, other than consecutive edges which touch at their common vertex. Different islands do not intersect or touch.

The input concludes with another mm lines, each describing a flight path. Each such line contains six integers x1x_1, y1y_1, z1z_1, x2x_2, y2y_2, z2z_2 (xi,yi,zi106|x_i|, |y_i|, |z_i| \leq 10^6, z_i > 0 and (x1,y1x_1, y_1) \neq (x2,y2x_2, y_2)). They specify that a flight takes place from (x1,y1,z1x_1, y_1, z_1) to (x2,y2,z2x_2, y_2, z_2).

输出格式

Output the smallest angle θ\theta (in degrees) that allows for a complete survey of the islands with the given flights. The answer should be exact to an absolute or relative error of 10610^{-6}. If there is no such angle, then output impossible\texttt{impossible}. The input is chosen such that if the coordinates of the island vertices are changed by at most ±108\pm 10^{-8}, then the answer will not change more than the allowed rounding error.

题目大意

有一个空间直角坐标系 OxyzO-xyz,在坐标平面 xOyxOy 上有 nn 个岛,每个岛是一个简单多边形。保证岛屿之间不重叠。

坐标系中有 mm 条飞机航线,航线是一条线段,两个端点的坐标分别是 (x1,y1,z1)(x_1,y_1,z_1)(x2,y2,z2)(x_2,y_2,z_2)。飞机可以沿任意一条飞机航线飞行。

现在要在飞机上装扫描相机。扫描相机的能扫描的范围取决于角度 θ\theta

飞机位于一点 (x,y,z)(x,y,z) 时,我们可以以 (x,y,z)(x,y,z) 为顶点做一个顶角为 2θ2\theta 的等腰三角形,这个等腰三角形所在的面和坐标平面 xOyxOy 垂直,同时也和这架飞机所在的飞机航线到坐标平面 xOyxOy的投影垂直。 将飞机位于 (x,y,z)(x,y,z) 时,能扫描到的线段定义为这个等腰三角形的底边。

对于一条航线,其覆盖的范围定义为当飞机在这条航线上运动时,所有能扫描到的线段组成的四边形。

求最小的 θ\theta(角度制),使得每个岛都至少完全位于一条航线的覆盖范围内。如果无论 θ\theta 取何值都不能满足条件,输出 impossible

1n,m1001\le n,m\le 100,多边形的边数不超过 100100,所有给出的坐标绝对值不超过 10610^6

3 2
3
20 30
50 50
10 50
4
40 20
60 10
75 20
60 30
4
45 60
55 55
60 60
55 65
0 30 20 78 70 5
55 0 20 70 60 10

48.031693036

1 1
4
0 0
10 0
10 10
0 10
5 5 10 15 5 10

impossible