eolymp
bolt
Try our new interface for solving problems
Problems

Draughts

Draughts

\textit{Draughts} (or \textit{checkers}) is a game played by two opponents, on opposite sides of a \textbf{10}×\textbf{10} board. The board squares are painted black and white, as on a classic chessboard. One player controls the dark, and the other the light pieces. The pieces can only occupy the black squares. The players make their moves alternately, each moving one of his own pieces. The most interesting type of move is \textit{capturing}: if a diagonally adjacent square contains an opponent’s piece, it may be captured (and removed from the game) by jumping over it to the unoccupied square immediately beyond it. It is allowed to make several consecutive captures in one move, if they are all made with a single piece. It is also legal to capture by either forward or backward jumps. \includegraphics{https://static.e-olymp.com/content/d7/d7bf1d0762ead631390f3a6e25d956329b875256.jpg} The board before and after a single move with two captures. You are given a draughts position. It is the light player’s turn. Compute the maximal possible number of dark pieces he can capture in his next move. \InputFile The first line of input contains the number of test cases \textbf{T}. The descriptions of the test cases follow: Each test case starts with an empty line. The following \textbf{10} lines of \textbf{10} characters each describe the board squares. The characters \textbf{#} and \textbf{.} denote empty black and white squares, \textbf{W} denotes a square with a light piece, \textbf{B} -- a square with a dark piece. \OutputFile For each test case print a single line containing the maximal possible number of captures. If there is no legal move (for example, there are no light pieces on the board), simply output \textbf{0}.
Time limit 1 second
Memory limit 256 MiB
Input example #1
2

.#.#.#.#.#
#.#.#.#.#.
.#.#.B.#.#
#.#.#.#.#.
.#.#.B.#.#
#.#.W.#.#.
.#.#.#.#.#
#.#.#.B.#.
.#.#.#.#.#
#.#.#.#.#.

.#.#.#.#.#
#.#.#.#.#.
.#.#.B.#.#
#.B.#.B.#.
.#.#.B.#.#
#.B.W.#.#.
.#.B.B.#.#
#.#.#.#.#.
.#.B.B.#.#
#.#.#.#.#.
Output example #1
2
4
Source 2013 ACM ICPC Central Europe Regional Contest, Kraków, November 15-17, Problem F