[Solution] Assiut Chess Solution Codeforces
This is an interactive problem.
ICPC Assiut Community decided to hold a unique chess contest, and you were chosen to control a queen and hunt down the hidden king, while a member of ICPC Assiut Community controls this king.
You compete on anchessboard, the rows are numerated from top to bottom, and the columns are numerated left to right, and the cell in row and column is denoted as .
In one turn you can move the queen to any of the squares on the same horizontal line, vertical line, or any of the diagonals. For example, if the queen was on square (cannot stay on its current cell., ), you can move to ( , ), ( , ), ( , ), or ( , ) where ( , , , ). Note that the queen
You win if the king has no valid moves. You lose if aftermoves of the queen the king still has valid moves.
The first line contains a single integer( ) — the number of test cases.
In each test case, you should print the queen’s starting cell immediately. If you placed the queen at the king’s cell, you will win immediately.
After that, you may make at mostmoves. Each move is made in the format , where and are two integers ( ) that denote the new row and column of the queen respectively. Your move should be a valid queen move.
After the initial queen placement and after each move you will receive a string Right“, “Left“, “Up“, “Down“, “Down-Right“, “Down-Left“, “Up-Left“, “Up-Right“, or “Done” if you win the game. You should consider “Done” as the end of each test case.that represents the direction of the king’s move. It will be one of the following: “
After printing a query do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:
- fflush(stdout) or cout.flush() in C++;
- System.out.flush() in Java;
- flush(output) in Pascal;
- stdout.flush() in Python;
- see documentation for other languages.
If at any point you make an invalid query or try to make more thanqueries for each test case, the game will terminate immediately and you will receive a Wrong Answer verdict.
1 Left Right Done
7 5 7 6 7 7
In the example, the hidden king was atat the start. The game follows like this:
Solution: Click here