Kicking Kangaroo

View as PDF

Submit solution

Points: 20 (partial)
Time limit: 3.0s
Memory limit: 512M

Author:
Problem type

problem header

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:

\displaystyle 
\text{Height}(t) = \text{Initial Height} + \text{Initial Vertical Velocity} \times t + \frac{a \times t^2}{2}.

Where a=-10. Her equation of motion in the x-direction is much simpler:

\displaystyle 
\text{X Position}(t) = \text{Initial X Position} + \text{Horizontal Velocity} \times t.

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 10^{-6} 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 2 \times 10^{-6}
  • 0 \leq r \leq 10^6
  • 0 \leq p \leq 10^6
  • 0 \leq k_0 \leq 10^9
  • 1 \leq v_0 \leq 10^9
  • 0 \leq g \leq 10^9
  • 1 \leq rectangle width, height \leq 10^9
  • -10^9 \leq x position, y position \leq 10^9
  • 0 \leq tap time \leq 10^9
  • -10^9 \leq initial y velocity of tap \leq 10^9
  • 1 \leq initial x velocity \leq 10^9
  • 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):

picture showing the rectangle positions and tap path of the kangaroo.


Comments

There are no comments at the moment.