Multiplayer Pong (Large)
Time limit5sMemory limit512 MB
Two teams alternately return a reflecting ball in fixed order, and the team whose player misses loses, so decide the winner and the loser return count.
- Level
Hard8 of 10
- Topics
- Math, Game theory, Simulation
- 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 back and forth between the two teams. Inside a team the players must return the ball in a fixed cyclic order. In a three-player team the first touch belongs to P1, the next to P2, the next to P3, and only then is it P1's turn again. Play continues until some player fails to reach the ball. The ball then leaves the field and that player's team loses.
The field is a rectangle of height and width . Its lower left corner is , the horizontal coordinate runs from to , and the vertical coordinate runs from to . The team called LEFT guards the wall with paddles, and the team called RIGHT guards the wall with paddles, one paddle per player. Every paddle of LEFT moves vertically at speed and every paddle of RIGHT moves vertically at speed , both in units per second. Paddles of the same team pass through each other freely.
The ball starts at height and horizontal position , and it moves units up and units to the right every second. Each player sees the starting position of the ball and then places their own paddle anywhere on their own wall before play begins. When the ball reaches a horizontal wall ( or ) it reflects, so the angle of incidence equals the angle of reflection. When the ball reaches a vertical wall, the player whose turn it is must have their paddle exactly at the arrival point. If the paddle is there, the ball bounces back. If it is not, that player's team loses. A player who is not on turn cannot touch the ball even when their paddle sits at the arrival point.
A velocity component can be . If is , the ball never reaches a vertical wall, so play never ends.
Determine the final result, assuming every player plays optimally.
Input
The first line contains , the number of test cases. Each test case consists of four lines.
The first line contains and , the height and the width of the field.
The second line contains and , the number of players on the team guarding and the number of players on the team guarding .
The third line contains and , the paddle speed of the first team and the paddle speed of the second team.
The fourth line contains , , and : the vertical position, the horizontal position, the vertical speed and the horizontal speed of the ball.
All values are integers.
Output
For each test case, print one line of the form Case #x: y, where is the test case number starting from 1 and is one of the following.
DRAWif the game can go on forever.LEFT zif the team guarding wins, where is the largest number of times the opposing team can bounce the ball.RIGHT zif the team guarding wins, where is the largest number of times the opposing team can bounce the ball.
Note

The picture shows the play of the first test case of the first example. The ball reaches the right wall at time , and the first RIGHT player intercepts it, for instance by starting with her paddle there and never moving it. It reaches the left wall at , where the single LEFT player returns it. At it is back on the right wall and the second RIGHT player can put his paddle at the bounce point. At it is on the left wall again and the LEFT player arrives just in time, covering three units of distance in exactly the one second she has. The next arrival on the right wall is too far away for the first RIGHT player. The second RIGHT player could reach it, but the cyclic order forbids him from touching the ball. If RIGHT had one more player, she would return the ball, and then LEFT would lose, because the ball would come back too high for the single LEFT player.