#P2571. Minimum Time with Conveyor Belts
Minimum Time with Conveyor Belts
Minimum Time with Conveyor Belts
On a 2D plane there are two conveyor belts represented by the line segments \(\overline{AB}\) and \(\overline{CD}\). The movement speeds are given as follows:
- Along \(\overline{AB}\), the speed is \(P\).
- Along \(\overline{CD}\), the speed is \(Q\).
- Anywhere else on the plane, the walking speed is \(R\).
The traveler starts at point \(A\), which is the beginning of the first belt, and his destination is point \(D\), which is an endpoint of the second belt. He may choose to enter or exit a conveyor belt at any point along its segment. When moving along a belt, his speed is boosted to \(P\) (for \(\overline{AB}\)) or \(Q\) (for \(\overline{CD}\)); when not on a belt, he moves at speed \(R\).
The task is to compute the minimum time required to travel from point \(A\) to point \(D\). The optimal route may involve any of the following strategies:
- Walking directly from \(A\) to \(D\).
- Walking from \(A\) to some point on \(\overline{CD}\) and then taking the conveyor belt from that point to \(D\).
- Riding the conveyor belt \(\overline{AB}\) for a portion of its length, then walking from that point to somewhere on \(\overline{CD}\) and riding \(\overline{CD}\) to \(D\).
- Using only \(\overline{AB}\) (riding for part of it) and then walking from the exit point to \(D\).
You are given the coordinates of points \(A, B, C, D\) and the speeds \(P, Q, R\). More specifically, the input gives 11 numbers in the following order:
(A_x\ A_y\ B_x\ B_y\ C_x\ C_y\ D_x\ D_y\ P\ Q\ R)
where \(A=(A_x,A_y)\), \(B=(B_x,B_y)\), \(C=(C_x,C_y)\), \(D=(D_x,D_y)\). Output the minimum time required to move from \(A\) to \(D\), with an absolute or relative error of at most \(10^{-6}\).
inputFormat
The input consists of a single line containing 11 space-separated numbers:
\(A_x\ A_y\ B_x\ B_y\ C_x\ C_y\ D_x\ D_y\ P\ Q\ R\)
\(A, B, C, D\) are the endpoints defining the two conveyor belts. Speeds \(P\) and \(Q\) are the speeds when traveling on conveyor belts \(\overline{AB}\) and \(\overline{CD}\) respectively, and \(R\) is the walking speed elsewhere on the plane.
outputFormat
Output a single number, which is the minimum required time to travel from \(A\) to \(D\). The answer is considered correct if the absolute or relative error does not exceed \(10^{-6}\).
sample
0 0 10 0 0 10 10 10 10 10 1
14.14213562