#P7449. [THUSC 2016] 星露谷物语
[THUSC 2016] 星露谷物语
Problem Description
Recently, Xiao Cong, in order to forget the noise of the city, came to Stardew Valley to start farming and make a fortune. However, because Xiao Cong spent all the money on gacha draws, there was not enough money to buy seeds. To collect enough money to raise pigs, Xiao Cong has to start a large-scale search for wild vegetables.
Stardew Valley is an infinite two-dimensional plane, and you can move freely on this plane. Xiao Cong may find wild vegetables on line segments on this plane, but these segments are directed. Xiao Cong must move along the direction of a segment in order to find wild vegetables. To find more wild vegetables, Xiao Cong wants to walk through all places where wild vegetables may appear in Stardew Valley. In other words, for each segment, Xiao Cong needs to traverse every point on that segment along its direction. Of course, Xiao Cong may choose to traverse a segment in multiple parts. More specifically, Xiao Cong may leave the segment at any position and enter the segment again at any position, as long as the union of the traveled paths covers this directed segment.
Xiao Cong wants to find a path as short as possible. This path should consist of line segments and cover the directed segments in Stardew Valley. Xiao Cong may choose any point in Stardew Valley as the starting point of the path, and it must also be the ending point, i.e. Xiao Cong must finally return to the starting position.
Now, Xiao Cong needs to write a Connect Four (Si Zi Qi) course assignment, and does not know how to plan the walking route to make the moving distance as short as possible, so this difficult task is handed to you, the smart one.
Note: If two segments partially overlap and have the same direction, then when you walk through the overlapping part, we consider that this part of both segments has been traversed.
Input Format
The first line contains an integer , representing the number of directed segments.
The next lines each contain four integers , meaning this segment is a directed segment from to .
Output Format
The first line should contain an integer , representing the number of points in the polyline path traveled by Xiao Cong, and it must satisfy . Then output lines, listing the points on the path in order. Each line should contain two floating-point numbers describing the - and -coordinates of a point. Here, should be kept to no more than digits after the decimal point.
3
0 0 0 100
0 100 100 100
100 100 0 0
4
0 0
0 100
100 100
0 0
3
0 0 0 100
1 51 1 49
0 100 0 0
5
0 0
0 100
1 51
1 49
0 100
Hint
This is an output-only problem. The input and checker will be provided in the attachments.
For each testdata, if your output format does not meet the requirements, or if the path you output does not traverse all the given directed segments, then this test point gets points. Otherwise, we will compute the length of your path, and calculate your score using scoring parameters :
The data guarantees that is large enough to ensure that a valid solution can get at least point.
Sample Explanation
For sample , Xiao Cong moved a total distance of , which is also the optimal solution for this sample.
For sample , in this solution, Xiao Cong moved a total distance of , but this is not the optimal solution for this testdata.
Translated by ChatGPT 5