#P7012. Draughts Maximum Capture
Draughts Maximum Capture
Draughts Maximum Capture
Draughts (or checkers) is played on a 10×10 board with alternating black and white squares. Only the black squares (those with \( (row + col) \% 2 = 0 \)) may hold pieces. The light player’s pieces are marked with W
and the dark player’s pieces with B
. Empty black squares are represented by .
while white (unplayable) squares are represented by #
.
A capture move is made by jumping diagonally over an adjacent opposing piece into an empty black square immediately beyond it. Multiple consecutive captures with the same piece are allowed, and jumps may be made in all four diagonal directions (both forward and backward).
Given a board position and that it is the light player’s turn, compute the maximum number of dark pieces that can be captured in one move.
inputFormat
The input consists of exactly 10 lines, each containing 10 characters. Each character represents a square on the board. For a square at position \( (r, c) \):
- If \( (r+c) \% 2 = 0 \) (a playable black square), it will be
W
for a light piece,B
for a dark piece, or.
for an empty square. - If \( (r+c) \% 2 = 1 \) (an unplayable white square), it is represented by
#
.
outputFormat
Output a single integer representing the maximum number of dark pieces that can be captured by the light player in a single move.
sample
.#.#.#.#.#
#.#.#.#.#.
.#.#.#.#.#
#.#B#.#.#.
.#.#W#.#.#
#.#.#.#.#.
.#.#.#.#.#
#.#.#.#.#.
.#.#.#.#.#
#.#.#.#.#.
1