Xorin, the main character from The Wolf of XOR Street, is now the youngest billionaire-in-coins ever. His wife, Xoranna, wants to steal his money. They are going to play the game Xorin is addicted to. Because Xoranna is a beautiful young blonde girl, she always starts. Your task is to help Xoranna steal the money from Xorin by winning the game. If you manage to do so, Xoranna is going to give you a quarter of the fortune.
The rules of the game are the following:
- The game is played in turns and Xoranna always starts the game.
- The game is played on a fixed size circular table of radius SZ.
- Every player has to put a radius 1 coin on the table without overlapping existing coins (they can, however, be tangent).
Interaction
Firstly, you should read the radius of the cicular board (SZ).
The turns alternate and you will have to place a coin in the first turn (print the x and the y coordinate of the coin).
The AI will put his coin after your turn (printing two values: x and y). It is guaranteed that the AI puts the coin in a valid position.
Note: After each command you should print a newline character and flush the output (using functions such as fflush(stdout)
or cout.flush()
).
The interactions stops when the AI can't make any valid move.
Constraints
- 5 ≤ SZ ≤ 20
- Every point of each coin must be on the table.
- Point (0, 0) is the center of the cicular board.
- We test the correctness of the placement of the coins with a 10-6 precision.
Helper functions
1 pair<double,double> rot(double x,double y,double x2,double y2,double U) 2 { 3 x -= x2; 4 y -= y2; 5 double new_x = x * cos(U) - y * sin(U); 6 double new_y = x * sin(U) + y * cos(U); 7 new_x += x2; 8 new_y += y2; 9 return make_pair(new_x,new_y); 10 } 11 12 pair<double,double> sim(double x,double y,double x2,double y2) 13 { 14 return make_pair(x2-x,y2-y); 15 }
Example interaction
User program | Simulator |
---|---|
10 | |
1 2 | |
-9 0 | |
3 2 | |
-8 -4 | |
10 5 |
First of all you should observe that the problem specifies that you can beat the AI. This suggests that the player that begins the game can win.
It is possible there are more than one winning strategy, but the problem ask you to find only one. Now, if you dont't have any idea where to start the resource code might be a hint.
The winning strategy offered by us is the following:
- Put a coin in the center of the table (0,0)
- When the AI places a coin you place a coin symetricly to the center. (if he places a coin at (x,y), you will place it at (-x,-y)) Because all the AI moves are valid, the mirror moves will also be valid.