eolymp
bolt
Try our new interface for solving problems
Problems

Shots at Walls

Shots at Walls

A new pistol is being tested. The pistol can fire shots with variant bullet speeds. In some points of time shots are fired from the point of origin with certain horizontal speeds, and in some other points of time walls are built on a horizontal platform. The walls are non-singular segments lying on lines that do not go through the point of origin. The walls may intersect. For processing of the test results, you are to determine the time that each shot bullet had been flying for. You can assume that the speed of the bullet after shot is constant. \InputFile Each line of the input begins with either "\textbf{shot}", "\textbf{wall}", or "\textbf{end}" (without quotes). The number of lines doesn't exceed \textbf{50000}. After "\textbf{shot}", the two coordinates of speed of the bullet are listed; the speed cannot be zero. After "\textbf{wall}", the four numbers follow, being the coordinates of wall's beginning and end. "\textbf{end}" denotes the end of the input. All the coordinates are integers whose absolute values doesn't exceed \textbf{10000}. All the events are listed in chronological order, and time intervals between the events exceed the time needed to build a wall, or the time needed for bullet to reach the next wall or end of the proving ground. \OutputFile For each of the shots, you must output the single number, on a line by itself: the time that the bullet had been flying for, with precision of \textbf{10^\{−6\}}. If the bullet doesn't hit any wall, you must output "\textbf{Infinite}" instead of a number.
Time limit 3 seconds
Memory limit 64 MiB
Input example #1
shot 1 0
wall 1 0 0 1
shot 1 1
shot -1 3
wall 1 0 -1 2
shot -1 3
wall 1 1 -1 1
shot -1 3
wall 2 3 2 -3
wall 3 -2 -3 -2
shot 1 -1
shot 40 -39
shot 9999 -10000
shot -1 -1
shot -3000 -2000
shot -3001 -2000
shot -3000 -2001
shot 1 0
shot 1 1
wall -1 2 10 -10
shot -1 1
shot 0 1
shot 1 1
shot 1 0
shot 1 -1
wall 0 -10000 -10000 0
shot -2 -1
end
Output example #1
Infinite
0.50000000000000000000
Infinite
0.50000000000000000000
0.33333333333333333333
2.00000000000000000000
0.05000000000000000000
0.00020000000000000000
2.00000000000000000000
0.00100000000000000000
Infinite
0.00099950024987506246
1.00000000000000000000
0.50000000000000000000
1.00000000000000000000
0.90909090909090909090
0.43478260869565217391
0.83333333333333333333
2.00000000000000000000
3333.33333333333333333333
Author Andrew Rumyantsev
Source Petrozavodsk summer training camp, August 2005