Multiplayer Pong (Small)
Time limit5sMemory limit512 MB
Decide which pong team misses first, or draws, from wall bounce heights with paddle speed limits and a fixed return order.
- Level
Medium6 of 10
- Topics
- Simulation, Math
- Solved
- No attempts yet
Problem
Two teams play pong. Each player controls one paddle, which we treat as a single point, and one ball travels between the teams. Inside a team the players must return the ball in a fixed cyclic order. In a three-player team the first return belongs to P1, the second to P2, the third to P3, and the fourth to P1 again. The moment the player whose turn it is fails to touch the ball, the ball leaves the field and that player's team loses.
The field is a rectangle of height and width . Take the lower left corner as the origin and write a point of the field as , so and . The first team has players and its paddles move only along the wall . The second team has players and its paddles move only along the wall . A paddle of the first team moves at most units per second, a paddle of the second team at most units per second. A paddle position is always a value in , and paddles of the same team pass through each other freely.
The ball starts at and moves units to the right and units up each second. The horizontal speed of the ball may be zero. When the ball reaches the wall or the wall it bounces with the angle of reflection equal to the angle of incidence, and its horizontal component is unchanged. At the moment the ball reaches or , the paddle of the player whose turn it is must be exactly at the height of the ball. If the paddle is there, the ball bounces under the same reflection rule and only the sign of the horizontal component flips. If it is not, that player's team loses.
Both teams see the initial position and velocity of the ball, and then they may place their paddles anywhere on their own wall before the ball starts moving. After that a paddle moves only within its own speed limit. Every player plays optimally.
The game can run for a long time. Determine the final result.
Input
The first line has the number of test cases . Then test cases follow, each on four lines.
- Line 1: the height and the width of the field.
- Line 2: the number of players of the team guarding the wall , and the number of players of the team guarding the wall .
- Line 3: the paddle speed of the first team and the paddle speed of the second team.
- Line 4: the initial height , the initial horizontal coordinate , the vertical speed , and the horizontal speed of the ball.
All values are integers and satisfy
Output
For each test case print one line in the form Case #x: y, where x is the test case number starting from 1 and y is one of these three answers.
DRAWif the game never ends.LEFT zif the team on the wall wins. Here is the number of times the other team returns the ball.RIGHT zif the team on the wall wins. Here is the number of times the other team returns the ball.
Explanation

The picture shows the play of the first example. The ball bounces off the right wall at time 0.375. The first player of the RIGHT team returns it, for instance by leaving her paddle at that point from the start. The LEFT player returns it off the left wall at 0.875, and at 1.375 the second player of the RIGHT team returns it off the right wall by putting his paddle at the bounce point. At 1.875 the ball bounces off the left wall again, and the LEFT player arrives just in time: she covers the distance of 3 exactly in the one second she has. The next point where the ball reaches the right wall is too far for the first player of the RIGHT team. The second player of the RIGHT team could catch that ball, but the order rule does not allow it. If the RIGHT team had one more player, she would return the ball, and then the LEFT team would lose, because the ball would come too far up for the single LEFT player to reach in time.