You and your development team are working on a hit new mobile game called "Kicking Kangaroo". In this game you control Kira, by commanding her to kick on command (with a screen tap), launching her into the sky with a particular horizontal velocity and initial vertical velocity. Kira, like all of us, is destined to experience the forces of gravity, and so her movement in between kicks can be modeled by the equations of motion with uniform acceleration:
Where . Her equation of motion in the x
direction is much simpler:
Kira is trying to get from her starting point to an end goal; a particular x
value. Blocking her path are various rectangles. If at any point Kira comes withing 10^6 units of a rectangle in either axis, before reaching her end goal, she loses the game. Additionally, if her height ever becomes negative, she loses the game.
Given the initial position of Kira, her goal, the rectangles, and all player taps, can you calculate whether Kira wins or loses the game?
Input
Input will begin with a single line containing 5 space separated integers:
 The number of rectangles,
r
 The number of player taps,
p
 The initial height of Kira,
k_0
 The initial horizontal velocity of Kira,
v_0
 The end goal of Kira,
g
Next follows r
lines of input, each containing 4 space separated integers:
 The width of this rectangle
 The height of this rectangle
 The
x
position of the centre of this rectangle  The
y
position of the centre of this rectangle
Next follows p
lines of input, corresponding to each tap, each containing 3 space separated integers:
 The time at which this tap occurred.
 The initial
y
velocity imparted onto Kira (This will reduce as time goes on, until the next tap)  The initial
x
velocity imparted onto Kira (This will stay the same until the next tap)
Output
If Kira wins the game, output a single line, containing the text YOU WIN
If Kira loses the game, output two lines, the first containing the text YOU LOSE
, and the second containing the exact x
position at which Kira loses the game. Any answer within relative or absolute error at most will be considered correct.
Constraints
 If Kira does not come into contact with any rectangles, she would also not come into contact with any rectangles if their height and width were increased by
r
p
k_0
v_0
g
 rectangle width, height

x
position,y
position  tap time
 initial
y
velocity of tap  initial
x
velocity  Rectangles do not overlap in
x
positions.
Example Run
For input
4 3 29 5 70
8 14 4 7
8 52 15 54
10 2 27 1
16 18 62 10
2 18 4
6 25 10
7 28 6
We should output
YOU LOSE
25.816263676
See the provided image for explanation (PLEASE IGNORE THE GREEN RECTANGLE):
Comments