Laser Marking
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Problem Statement
There is a printing machine that prints line segments on the -plane by emitting a laser.
-
At the start of printing, the laser position is at coordinate .
-
When printing a line segment, the procedure below is followed.
- First, move the laser position to one of the endpoints of the line segment.
- One may start drawing from either endpoint.
- Then, move the laser position in a straight line from the current endpoint to the other endpoint while emitting the laser.
- It is not allowed to stop printing in the middle of a line segment.
- First, move the laser position to one of the endpoints of the line segment.
-
When not emitting the laser, the laser position can move in any direction at a speed of units per second.
-
When emitting the laser, the laser position can move along the line segment being printed at a speed of units per second.
-
The time required for operations other than moving the laser position can be ignored.
Takahashi wants to print line segments using this printing machine.
The -th line segment connects coordinates and .
Some line segments may overlap, in which case he needs to print the overlapping parts for each line segment separately.
What is the minimum number of seconds required to complete printing all the line segments when he operates the printing machine optimally?
Constraints
- All input values are integers.
- ( )
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Your output will be considered correct if the absolute or relative error from the true value does not exceed .
Sample Input 1
3 2 1
1 3 2 1
0 2 0 0
3 0 2 0
Sample Output 1
6.44317475868633722080
- Emit the laser while moving the laser position from to , printing the second line segment.
- This takes seconds.
- Move the laser position from to without emitting the laser.
- This takes seconds.
- Emit the laser while moving the laser position from to , printing the first line segment.
- This takes seconds.
- Move the laser position from to without emitting the laser.
- This takes second.
- Emit the laser while moving the laser position from to , printing the third line segment.
- This takes second.
- The total time taken is $2 + (\sqrt{2}/2) + \sqrt{5} + (1/2) + 1 \approx 6.443175$ seconds.
Sample Input 2
2 1 1
0 0 10 10
0 2 2 0
Sample Output 2
20.97056274847714058517
Sample Input 3
6 3 2
-1000 -1000 1000 1000
1000 -1000 -1000 1000
-1000 -1000 1000 1000
1000 -1000 -1000 1000
1000 1000 -1000 -1000
-1000 1000 1000 -1000
Sample Output 3
9623.35256169626864153344
Multiple line segments overlap here, and you need to print the overlapping parts for each line segment separately.
Sample Input 4
6 10 8
1000 1000 -1000 -1000
1000 -1000 -1000 -1000
-1000 1000 1000 1000
-1000 1000 -1000 -1000
1000 1000 1000 -1000
1000 -1000 -1000 1000
Sample Output 4
2048.52813742385702910909
SDNU_ACM_ICPC_2024_WEEKLY_PRACTICE_1st
- Status
- Done
- Rule
- ACM/ICPC
- Problem
- 8
- Start at
- 2024-10-27 18:30
- End at
- 2024-10-27 21:30
- Duration
- 3 hour(s)
- Host
- Partic.
- 39