#P2288. [HNOI2005] 纸片覆盖
[HNOI2005] 纸片覆盖
Description
Xiaofu, who likes geometry, encountered the following problem: one day he drew lines on a white sheet of paper, and then cut out a small -gon (simple polygon).
He wants to place this small paper piece on the sheet so that the total length of the lines it covers is maximized. The polygon piece cannot be flipped or rotated; it can only be translated. If some portion of a line happens to coincide with an edge of the polygon, then that segment is considered covered.
Can you help him solve this problem?
Input Format
Read from the file input.txt. The first line contains two numbers and , where , denoting the number of lines and the number of edges of the polygon, respectively.
Each of the next lines describes a line, with real numbers , representing a line passing through and .
Each of the next lines gives the vertices of the polygon in either clockwise or counterclockwise order, with real numbers , representing the coordinates of a vertex.
Assume all input real numbers are between and , and have no more than decimal places. The input polygon is guaranteed to be non-self-intersecting, and no three consecutive points are collinear.
Output Format
The output file output.txt contains only one number , the maximum total length of line segments that the input polygon can cover, accurate to decimal places.
3 5
6 1 2 5
1 2 8 4
4 -1 5 6
1 0
5 -1
4 2
7 3
4 4
11.933
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号