Assiut Chess solution codeforces

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 an 8×88×8 chessboard, the rows are numerated from top to bottom, and the columns are numerated left to right, and the cell in row xx and column yy is denoted as (x,y)(x,y).

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 (4455), you can move to (q1q155), (44q1q1), (q1q19q19−q1), or (q2q2q2+1q2+1) where (1q181≤q1≤8q14q1≠41q271≤q2≤7q24q2≠4). Note that the queen cannot stay on its current cell.

In one turn, the king can move “Right”, “Left”, “Up”, “Down”, “Down-Right”, “Down-Left”, “Up-Left”, or “Up-Right” such that he doesn’t get out of the board. The king cannot move into a cell that is on the same row, column or diagonal with the queen (including the position of the queen itself). For example, if the king was on square (4455), he can move to (4+k14+k15+k25+k2) where (1k1,k21−1≤k1,k2≤1(k1,k2)(0,0)(k1,k2)≠(0,0)).

At the start of the game, you should place the queen at any location on the board, and this is done once per game. After that the king is secretly placed at any cell different from the queen’s location. You do not know the position of the king. Then, the king and the queen take turns with the king moving first. The king moves to one of the possible directions (“Right”, “Down”, “Up-Left”, etc.), and you are only given the direction it moves to. After that, you should move your queen by declaring the square to which your queen will move. The game follows like this until you win the game or run out of moves.

You win if the king has no valid moves. You lose if after 130130 moves of the queen the king still has valid moves.

Input Assiut Chess solution codeforces 

The first line contains a single integer tt (1t601≤t≤60) — the number of test cases.

Interaction

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 most 130130 moves. Each move is made in the format xx yy, where xx and yy are two integers (1x,y81≤x,y≤8) 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 ss that represents the direction of the king’s move. It will be one of the following: “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.

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 than 130130 queries for each test case, the game will terminate immediately and you will receive a Wrong Answer verdict.

Example Assiut Chess solution codeforces 

input

Copy
1
Left
Right
Done

output

Copy
7 5
7 6
7 7
Note Assiut Chess solution codeforces 

In the example, the hidden king was at (8,8)(8,8) at the start. The game follows like this:

 

standard input/output

1 s, 256 MB

Submit Add to favourites
B
standard input/output

2 s, 256 MB

Submit Add to favourites
C
standard input/output

2 s, 256 MB

Submit Add to favourites
D
standard input/output

2.5 s, 256 MB

Submit Add to favourites
E
standard input/output

1 s, 256 MB

Submit Add to favourites

Leave a Comment