About Love...
Time limit2sMemory limit1024 MB
Two moving line segments drift at constant velocities; find the earliest time they touch, or report -1 if they never do.
- Level
Hard8 of 10
- Topics
- Geometry, Binary search, Math, Implementation
- Solved
- No attempts yet
Problem
A spider and a spideress are floating across a lake on two twigs. They cannot swim, so they can meet only when the twigs touch.

Assume the twigs are line segments and move at constant velocities. Determine how long the unfortunate arthropods must wait to meet.
Input
The input file contains 12 numbers: , , , , , , , , , , , . The endpoints of the first segment are and , the endpoints of the second segment are and , the velocity of the first segment is , and the velocity of the second segment is . All numbers are integers with absolute value at most . At the initial moment the twigs do not touch.
It is guaranteed that the twigs have nonzero length.
Output
Print the time until the earliest moment when the twigs touch, with an error of at most . If the twigs never touch, print .