#P7012. [CERC2013] Draughts

[CERC2013] Draughts

题目描述

Draughts (or checkers) is a game played by two opponents, on opposite sides of a 10×1010 \times 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 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.

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.

输入格式

The first line of input contains the number of test cases TT . The descriptions of the test cases follow:

Each test case starts with an empty line. The following 1010 lines of 1010 characters each describe the board squares. The characters # and . denote empty black and white squares, WW denotes a square with a light piece, BB - a square with a dark piece.

输出格式

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 00 .

题目大意

国际跳棋(或称跳棋)是一种由两个对手在 10×1010 \times 10 的棋盘上进行的游戏。棋盘上的方块是黑色或白色的,就像经典的国际象棋棋盘一样。玩家一方控制黑棋,另一方控制白棋。棋子只能占据黑色的格子。棋手们交替走棋,各自移动自己的一个棋子。

最有趣的走法是吃掉:如果一个对角线相邻的格子里有对手的棋子,可以通过跳过它到紧挨着它的未被占领的格子来吃掉(并从游戏中删除被吃掉的这个棋子)。允许在一步棋中用一个棋子连续吃掉几个棋子。通过向前或向后的跳跃来吃子也是合法的。

你会得到一个棋子的位置。现在轮到白方了。计算他在下一步棋中能吃掉的最大可能的黑棋数量。

输入格式

输入的第一行包含测试用例 TT 的数量。接下来是测试用例的描述。

每个测试用例以空行开始。接下来的 10 行,每行都有 10 个字符,描述棋盘的方格。字符 # 和 . 表示空的黑色和白色方块,W 表示有浅色棋子的方块,B 表示有深色棋子的方块。

输出格式

对于每个测试案例,输出一行一个整数,代表最多可以吃黑子的个数。如果没有合法的棋步(例如,棋盘上没有白棋),只需输出 0。

2

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

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

2
4

提示

Time limit: 2 s, Memory limit: 128 MB.