One day, Jonathan is stuck inside of a large maze. Completely lost, he asks Raymond to help him get out of the maze. Unwilling to see Jonathan escape from the maze without thought, Raymond decides to only give him hints.
"Your starting point is at , and the exit is at ," says Raymond.
"That seems easy...then why can't I get out of this maze?" replies Jonathan.
"Your path is blocked by several walls. There are walls in the maze. The walls can be represented as line segments. The wall has two different endpoints and . You cannot intersect these walls, but you can walk along them."
"That sounds simple enough."
What is the shortest distance that Jonathan has to travel to exit the maze?
Constraints
The absolute value of any coordinate will not exceed .
The start point and exit are located at distinct points and will not be on any line.
A line's endpoints will not be on another line anywhere except the latter line's endpoints. If two lines share an endpoint, the angle will be between and .
Subtask | Points | Additional Constraints | |
---|---|---|---|
1 | 3 | No additional constraints. | |
2 | 3 | All points are pairwise distinct. This includes the starting point, the exit, and all endpoints. | |
3 | 4 | No additional constraints. | |
4 | 5 | No additional constraints. |
Input Specification
The first line of input will contain five space-separated integers, , , , , and .
lines of input will follow. The line will contain four space-separated integers, , , , and .
Output Specification
On a single line, output the shortest distance that Jonathan has to travel to exit the maze. Your answer will be judged as correct if it has an absolute or relative error no greater than .
If it is not possible for Jonathan to travel to the exit, print No exit
.
Sample Input 1
1 0 0 1 1
1 0 0 1
Sample Output 1
2.00000000
Diagram for Sample 1
The blue points represent the starting and ending points, the green line represents the wall, and the dotted red line shows an optimal path.
Sample Input 2
4 0 0 5 5
0 2 1 1
1 1 2 2
3 3 4 4
4 4 5 3
Sample Output 2
7.07106781
Diagram for Sample 2
The blue points represent the starting and ending points, the green lines represent the walls, and the dotted red line shows the optimal path.
Comments