Count the black kings that can capture all white kings in one chain of diagonal jumps.
Medium5BacktrackingDFSNo attempts yetTime limit2sMemory limit256 MBCheckers is played on a square board of n×n cells. A real game uses n equal to 8, 10, or 12, but in this problem n is between 2 and 26. The cells are colored red and black so that two cells sharing a side never have the same color, and every piece moves only on the black cells.
The two players are Black and White, and their pieces carry the same colors. Checkers has two kinds of pieces, checkers and kings, but this problem uses kings only.
A king jumps a piece of the other color standing diagonally next to it and lands on the cell directly beyond that piece, capturing it. The captured piece leaves the board at once. After a capture the same king may keep jumping while another piece of the other color can be jumped, and the whole chain of jumps counts as one move. A king may jump in any of the four diagonal directions.
A jump is legal only if the piece to be jumped is diagonally adjacent to the jumping king and the cell directly beyond that piece lies inside the board and is empty.

It is Black's turn. Given a position, count the black kings that can capture every white king in a single move. If the board holds no white king, no jump exists, so the answer is 0.
The first line contains the board size n (2≤n≤26). Each of the next n lines describes one row of the board and contains exactly n characters. Each character is one of ., _, B, W:
. is a red cell. No king can stand on a red cell._ is an empty black cell.B is a black cell holding a black king.W is a black cell holding a white king.The given board is always well formed: black and red cells alternate along every row and every column, and no king stands on a red cell.
Print one integer, the number of black kings that can capture every white king in a single move.