#P14189. [ICPC 2024 Hangzhou R] Catch the Star
[ICPC 2024 Hangzhou R] Catch the Star
题目描述
BaoBao bought a telescope to observe a star in the night sky. The star is represented as a convex polygon . However, there are convex polygonal moons that could obstruct his view. BaoBao can place his telescope anywhere on the -axis between points and , but he place it exactly at or .
Your task is to help BaoBao find the total length of the segments on the x-axis where he can position his telescope such that he has an unobstructed view of the star , and whether he find a position at all. An unobstructed view means that no line segment from the chosen point on the x-axis to any point inside or on properly intersects any of the moons . The line segment is allowed to touch the boundary of the moons but not cross through them.
输入格式
There are multiple test cases. The first line of the input contains an integer () indicating the number of test cases. For each test case:
The first line contains three integers , , and (, ), denoting the number of moons and the range for telescope placement.
The second line describes the star and begins with an integer (), denoting the number of vertices of , followed by integers $x_{0,1},y_{0,1},x_{0,2},y_{0,2},\cdots,x_{0,k_0},y_{0,k_0}$ (), where is the coordinate of the -th vertex of in counter-clockwise order.
For the following lines, the -th line describe moon . Each line begins with an integer (), denoting the number of vertices of , followed by integers $x_{i,1},y_{i,1},x_{i,2},y_{i,2},\cdots,x_{i,k_i},y_{i,k_i}$ (), where is the coordinate of the -th vertex of in counter-clockwise order.
It is guaranteed that and are convex polygons. The star , the moons , and the segment from to do not touch or intersect with each other. However, different moons can intersect with each other. No three consecutive vertices of the same polygon are collinear.
It's guaranteed that the sum of of all test cases does not exceed . It is also guaranteed that the total number of polygons of all test cases (which is ) does not exceed .
输出格式
For each test case, output a single line containing the total length of valid segments on the x-axis, strictly between and , where BaoBao can place his telescope to see without obstruction. If there's no valid point between and , output instead.
Your answer would be considered correct if the relative or absolute error does not exceed .
2
4 -8 8
3 -7 7 -6 8 -7 8
3 -9 -2 -7 3 -9 -1
3 -2 3 0 2 -4 5
3 5 1 5 3 4 2
3 1 -1 2 -2 3 -1
5 -8 8
5 -14 -3 -10 -2 -9 2 -10 4 -12 5
3 -16 0 -15 0 -15 1
3 -15 6 -9 5 -15 7
3 -10 5 -9 5 -10 6
3 -7 3 -3 2 -8 4
3 -6 -1 -6 -2 -5 -1
9.404761904761905
6.000000000000000
3
1 -4 4
3 -2 6 0 5 2 6
3 -3 1 3 1 0 4
3 -2 2
3 -2 4 2 4 0 6
3 -2 2 -1 2 -2 3
3 1 2 2 2 2 3
3 -2 -1 0 -3 2 -1
1 1 2
3 -8 0 -7 0 -8 1
3 -5 0 -4 -1 -4 0
-1.000000000000000
0.000000000000000
1.000000000000000
1
1 -744567334 955216804
5
-781518205 -852078097
-781516900 -852078384
-781516392 -852076569
-781518329 -852076047
-781519925 -852077600
5
-393011614 -131855702
-393010699 -131856607
-393008846 -131856475
-393009388 -131854587
-393010201 -131854694
1699779738.691979192313738
提示
For the first sample, the first test case is illustrated below; the telescope can be located between and , or and .
:::align{center}
:::
The second test case is illustrated below; the telescope can be located between and .
:::align{center}
:::
Note that the input format in the third sample is for presentation purposes only, because we cannot print all the coordinates in one line without exceeding the width of the paper. Please refer to the other samples for more accurate input formatting.