The $$$n$$$-checkers board is an $$$n \times n$$$ board with squares alternating between white and black, with the square in the top-left corner being white. A square may be empty or, if it is black, contain a piece.
On their turn, a player must choose one of their pieces to move. The chosen piece may capture an opponent's piece if that piece is on a diagonally adjacent square and the next square in the same diagonal direction is empty. In this case, the chosen piece "jumps" over the opponent's piece, moves to the immediately following empty square, and removes the opponent's piece from the board. After a capture, the player may continue the move with the same chosen piece.
In the official rules of $$$n$$$-checkers, there is a majority-capture rule: if on their turn a player has the opportunity to capture opponent pieces, they must perform a sequence of moves that results in the largest possible number of captured pieces.
During the final of the Minas Gerais $$$n$$$-checkers Tournament, a dispute arose between the finalists. Alice, playing with the black pieces, accused Bob, playing with the white pieces, of having made an illegal move. Bob claims he captured as much as he could, but Alice says there was a longer path. Write a program that determines the maximum number of pieces Bob can capture in one move sequence.
The first line contains a single integer $$$n$$$ $$$(4 \leq n \leq 14)$$$, the dimension of the board.
Then $$$n$$$ lines follow, each with $$$n$$$ characters representing the board. Each line contains only the characters 'B', 'P', and '.', representing white pieces, black pieces, and empty squares, respectively. The letters come from Portuguese: 'B' for white pieces and 'P' for black pieces.
The board will contain at least one piece of each color, and no piece will be on a white square.
Print the maximum number of pieces Bob can capture.
8.P.P.P.PP.P.P.P..P.....P..P.P........B..B.B...B..B.B.B.BB.B.B.B.
2
8..........P.P.P...........P.P.P........B....P......B............
6
14.B.P.B.B.P.B.PB...B...B...B..P.B.P.P.B.P.B..B...B...B....B.P.B.B.P.B.PB...B...B...B..P.B.P.P.B.P.B..B...B...B....P.B.P.P.B.P.BB...B.B.B...B..B.P.B.B.P.B.P..B...B...B....P.B.P.P.B.P.BB...B.B.B...B.
12
Explanation for example 1
Explanation for example 2
| Name |
|---|


