#P6253. Reconstructing a Checkers Game Setup
Reconstructing a Checkers Game Setup
Reconstructing a Checkers Game Setup
Your university's board game club hosted a Checkers tournament. Unfortunately, you lost most of your notes and all that remains is a list of moves performed during some games. Your task is to reconstruct an initial board configuration (setup) that allows the moves to be legally played in sequence according to the following rules.
Checkers (or English Draughts) is played on the dark squares of an \(8\times8\) board. There are two players, Black and White, who alternate turns. Each piece is either a normal man or a promoted king. A piece occupies one dark square.
A turn consists of moving a single piece in one of two ways:
- Simple move: Shift the piece diagonally to an unoccupied adjacent dark square. A man may only move in the two diagonal directions toward the opponent’s side (for Black toward the bottom and for White toward the top). A king may move in all four diagonal directions.
- Jump move: Jump over an adjacent enemy piece (diagonally) landing in the unoccupied square immediately beyond it, capturing (removing) that piece. Men jump only forward (as described above) while kings may jump in any diagonal direction. A multiple jump (sequence of jumps with the same piece) is permitted and, once begun, must be continued until no further jump is possible.
In addition:
- If a jump is available at the start of a turn, the jump must be taken.
- If a man reaches the farthest row from its side (row \(8\) for Black and row \(1\) for White), it is promoted: it is removed and replaced by a king of the same color. Note that a man may not be promoted in the middle of a jump sequence.
Given a list of moves, design any initial board configuration such that the moves can be legally executed in sequence. The initial configuration must not contain any Black man on row 8 or White man on row 1 (since they would have already been promoted). You do not need to ensure that the configuration is reachable in a real game, only that it allows the move sequence to be executed legally.
Notes on Coordinates: The board uses 1-indexed coordinates. The first number denotes the row and the second number denotes the column. For example, (3,2) refers to row 3, column 2. All moves will lie on dark squares.
Move Format: Each move is provided on one line. The line starts with an integer \(k\) (\(k\ge2\)) denoting the number of positions in the move, followed by \(2k\) integers. These integers represent \(k\) positions in order; if \(k=2\) the move is a simple move, and if \(k>2\) the move is a jump move. For a simple move the difference between the coordinates will be 1 in absolute value. For a jump move the difference between consecutive coordinates will be 2 in absolute value. Note that for a man the allowed direction is forward (for Black, row increases; for White, row decreases), and if any step does not follow that rule then the moving piece must be a king.
inputFormat
The first line contains an integer \(N\) (the number of moves). Each of the next \(N\) lines describes a move in the following format:
k r1 c1 r2 c2 ... rk ck
Here, \(k\) (\(k\ge2\)) is the number of positions in the move, and \(r_i, c_i\) are the 1-indexed row and column coordinates of the positions.
Black moves first, and players alternate moves. If a move contains any step that is not in the forward direction (for a man: for Black, row difference should be \(+1\) for simple moves and \(+2\) for jumps; for White, \(-1\) and \(-2\) respectively), then the moving piece is assumed to be a king.
outputFormat
Output the initial board configuration as 8 lines, each containing 8 characters. The characters represent the state of each square:
.
denotes an empty square.b
denotes a Black man andB
denotes a Black king.w
denotes a White man andW
denotes a White king.
The top line corresponds to row 1 and the bottom line corresponds to row 8. Note that the initial configuration must not have a Black man on row 8 or a White man on row 1.
sample
1
2 3 2 4 3
........
........
.b......
........
........
........
........
........
</p>