#B4183. Determine the Elephant's Position on the Chessboard
Determine the Elephant's Position on the Chessboard
Determine the Elephant's Position on the Chessboard
An 8×8 chessboard is given, where the cells are identified by their coordinates \((r, c)\) with \(1 \le r, c \le 8\). An "Elephant" piece was placed on one of the cells (except the four corners \((1,1), (1,8), (8,1), (8,8)\)) and it "attacks" (or affects) its own cell as well as every cell on the two diagonals passing through it. In other words, if the Elephant was placed at \((r, c)\), then every cell \((x, y)\) satisfying either \[ x-y = r-c \quad \text{or} \quad x+y = r+c \] was marked red.
After the piece was removed, the board remained with a red pattern. Given that pattern, your task is to determine the original position of the Elephant.
Note: It is guaranteed that the red pattern corresponds uniquely to one valid position of the Elephant, and that the Elephant was not placed in any of the four corner cells.
inputFormat
The input consists of 8 lines, each containing 8 integers separated by spaces. The integer on the \(i\)-th line and \(j\)-th position is 1
if the cell \((i, j)\) is marked red, and 0
otherwise.
outputFormat
Output two integers separated by a space: the row and column index of the Elephant's original position.
sample
0 1 0 1 0 0 0 0
0 0 1 0 0 0 0 0
0 1 0 1 0 0 0 0
1 0 0 0 1 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 1
0 0 0 0 0 0 0 0
2 3