#P10864. Go Game Capture Simulator

    ID: 12908 Type: Default 1000ms 256MiB

Go Game Capture Simulator

Go Game Capture Simulator

Blue-edged Shot is forbidden from playing Genshin Impact by LeavingZ, so she turned to the game of Go.

A game of Go involves two players, one playing with Black stones and the other with White stones. The players take turns placing stones on a board of size \(19\times 19\) intersections, with Black playing first (on odd-numbered moves) and White playing on even-numbered moves. The intersections are labeled \((x,y)\) where \((1,1)\) is the top-left and \((19,19)\) is the bottom-right.

Two intersections \((x_1,y_1)\) and \((x_2,y_2)\) are adjacent if and only if \(|x_1-x_2|+|y_1-y_2|=1\). Adjacent stones of the same color form a group. The liberties of a stone is defined as the number of adjacent intersections (up, down, left, right) that are empty. The liberties of a group is the sum of the liberties of all its stones. Note that if an empty intersection touches more than one stone of the same group, it contributes to the liberty count of each stone independently. In formula, the liberties of a group is given by \(\text{liberties}=\sum_{s\in\text{group}}\text{(number of empty adjacent intersections to }s\text{)}\). A group with zero liberties is considered dead and must be removed from the board.

After a move is made, the removal process occurs in two steps:

  1. Remove all opponent groups that have zero liberties.
  2. Recalculate the liberties for the current player's groups and remove any group that now has zero liberties.

Specifically, when Black plays (odd-numbered moves), remove dead White groups first then check Black groups; when White plays (even-numbered moves), remove dead Black groups first then check White groups.

You are given a sequence of moves (each move places a stone on an empty intersection, regardless of real Go legality). After each move, output the number of Black and White stones removed due to that move. The output for each move should list first the number of Black stones removed and then the number of White stones removed.

inputFormat

The first line contains an integer \(m\) (\(1\le m\le 361\)), the number of moves.

Each of the following \(m\) lines contains two integers \(x\) and \(y\) (\(1\le x,y\le 19\)), representing the row and column where a stone is placed.

outputFormat

For each move, output two integers separated by a space: the number of Black stones removed and the number of White stones removed as a result of that move.

sample

4
10 10
10 11
9 10
9 11
0 0

0 0 0 0 0 0

</p>