Game of the Amazons
Tag(s):

## Medium-Hard

Problem
Editorial
Analytics
Game of the Amazons (Wiki) is a two-player board game which is played on a 10x10 grid of cells. Each player has four amazons having initial configuration as shown in the image.

A move consists of two subsequent actions:

1. One moves one of one's own amazons one or more empty squares in a straight line (orthogonally or diagonally), exactly as a queen moves in chess; it may not cross or enter a square occupied by an amazon of either color or an arrow.
2. After moving, the amazon shoots an arrow from its landing square to another square, using another queen-like move. This arrow may travel in any orthogonal or diagonal direction (even backwards along the same path the amazon just traveled, into or across the starting square if desired). An arrow, like an amazon, cannot cross or enter a square where another arrow has landed or an amazon of either color stands. The square where the arrow lands is marked to show that it can no longer be used.

The last player to be able to make a move wins.

Now your aim is to implement a bot that plays Game of Amazons with bots of other participants. The program you submit will run for each move played by your player in the game.

Input
The input is a 10x10 matrix consisting only of 0, 1, 2 and -1. Then another line follows which contains a number 1 or 2, which is your player id. The difference between player 1 and 2 is that player 1 plays first in start of the game.

In the given matrix, top-left is [0, 0] and bottom-right is [9, 9]. The coordinate of a cell is represented by [row, column]. Rows increases from top to bottom and column increases from left to right.

The cell marked 0 signifies that the cell is empty. The cell marked 1 means it contains one of player 1's amazons which are white in appearance. The cell marked 2 means it contains one of player 2's amazons which are black in appearance. The cell marked -1 means that it has been blocked by an arrow.

Output
Print the coordinates [row, column] of the amazon that you wish to move.
In the next line, print the coordinates of cell [row, column] where you want to move your amazon to.
In next line, print the coordinates of cell [row, column] where you want to throw an arrow.

Starting state
0 0 0 2 0 0 2 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0 2
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 1 0 0 1 0 0 0

Update: The final leaderboard is live now.
SAMPLE INPUT
0 0 0  2 0 0 2 0  0  0
0 0 0 -1 0 0 0 0  0  0
0 0 0  0 0 0 0 0  0  0
0 0 0  2 0 0 0 0  2  0
0 0 0  0 0 0 0 0  0  0
0 0 0 -1 0 0 0 0  0  0
1 0 0  1 0 0 0 0 -1  1
0 0 0  0 0 0 0 0  0  0
0 0 0  0 0 0 0 0  0  0
0 0 0  0 0 0 0 1  0 -1
1
SAMPLE OUTPUT
6 0
8 0
7 1

Explanation
This is player 1's turn, and the player moves his/her amazon from cell [6, 0] to cell [8, 0] and shoots the arrow on cell [7, 1].

After his/her move the state of game becomes:
0  0 0  2 0 0 2 0  0  0
0  0 0 -1 0 0 0 0  0  0
0  0 0  0 0 0 0 0  0  0
0  0 0  2 0 0 0 0  2  0
0  0 0  0 0 0 0 0  0  0
0  0 0 -1 0 0 0 0  0  0
0  0 0  1 0 0 0 0 -1  1
0 -1 0  0 0 0 0 0  0  0
1  0 0  0 0 0 0 0  0  0
0  0 0  0 0 0 0 1  0 -1

This generated state will be fed as input to alternate player's bot code. Again the new generated state after alternate player's bot makes a move, will be fed as input to player 1. This goes on until game is finished or aborted.
Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

## CODE EDITOR

Initializing Code Editor...