407807: GYM102896 I Interactive Knockout

Memory Limit:512 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

I. Interactive Knockouttime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

This is an interactive problem. You are to defeat a randomly moving jury in a series of independent rounds of the game.

The game is played on a hexagonal field with axial coordinates. The field is bounded by a hexagon with vertices in cells (n, 0), (0, n), ( - n, n), ( - n, 0), (0,  - n), and (n,  - n). In all test cases, except for the sample test case in this statement, which is not present in the real test set, n = 20.

There are two players — you and the jury. You start in the cell ( - n / 2, 0) and the jury starts in the cell (n / 2, 0). Players take turns, you move first.

A field for n = 4 (the blue cell is your starting cell and the red cell is the starting cell for the jury).

At each turn, the player moves to any cell adjacent by side, which does not contain the opponent and has not been destroyed. After that, the previously occupied cell is destroyed and is not available to players on the following turns anymore. The player who cannot move to any adjacent cell loses the game.

The jury did not come up with any smart algorithm to play this game, so they've decided to move equiprobably randomly to any valid adjacent cell on each turn.

You need to show your complete dominance — win all of t independent rounds of the game.

Interaction

In the first line, you are given integers t and n — the number of independent rounds of the game you need to win, and the field size (1 ≤ t ≤ 50; n = 20 except for the sample test case, which is not present in the real test set).

Each turn, you need to output a line with the direction of your move — two integers dx, dy, where , (0, 1), ( - 1, 1), ( - 1, 0), (0,  - 1), (1,  - 1)}. After that, read one line in the following format:

  • token "move" and two integers dx, dy — direction (dx, dy) where the jury moved. It is guaranteed to be chosen equiprobably randomly;
  • token "win", if the jury doesn't have any valid cells to move to. In this case, you should immediately start playing the next game, or finish your program with the exit code 0 if all t rounds were played.
  • token "lose", if you made an invalid move. In this case, you should finish your program with the exit code 0 to get an adequate verdict of "Wrong answer".

It is guaranteed that there are at most 100 tests (with at most 50 game rounds in each test) for a total of at most 5000 game rounds that you shall win. The jury uses a fixed random seed for each test.

ExampleInput
2 4

move -1 1

move -1 1

move -1 1

move 0 1

move -1 0

win

move 0 -1

move -1 0

lose
Output

0 1

0 1

0 1

-1 0

-1 1

1 0

1 0

1 -1

1 0
Note

Note that the interaction in the sample test case results in the "Wrong answer" verdict, as only 1 round out of 2 is won. The two rounds played are shown below.

  The starting player wins (on the left) and loses by making an invalid move (on the right).

加入题单

上一题 下一题 算法标签: