#P5380. Simulating Duck Chess Move Sequences
Simulating Duck Chess Move Sequences
Simulating Duck Chess Move Sequences
In Duck Chess, two players (red and blue) take turns moving their own pieces on a 10×9 board. Each piece has its own moving rules defined by relative moves from its current position (x,y) (with the board rows numbered 1 to 10 and columns 1 to 9). The seven types of pieces and their move rules are:
- captain: May move to (x+1,y), (x-1,y), (x,y+1), or (x,y-1).
- guard: May move diagonally one step: (x+1,y+1), (x+1,y-1), (x-1,y+1), or (x-1,y-1).
- elephant: For each s_x,s_y in {1, -1} if the adjacent cell (x+s_x, y+s_y) is empty then (x+2*s_x, y+2*s_y) is reachable.
- horse: For each s_x,s_y in {1, -1} two kinds of moves are allowed:
- If (x+s_x,y) is empty then (x+2*s_x, y+s_y) is reachable.
- If (x,y+s_y) is empty then (x+s_x, y+2*s_y) is reachable.
- car: Moves like a rook. It can move horizontally or vertically any number of cells, but cannot jump over other pieces. It stops before a blocking piece. If the blocking piece belongs to the opponent, it may be captured.
- duck: For each s_x,s_y in {1, -1} two moves are defined:
- If both (x+2*s_x, y+s_y) and (x+s_x, y) are empty, then (x+3*s_x, y+2*s_y) is reachable.
- If both (x+s_x, y+2*s_y) and (x, y+s_y) are empty, then (x+2*s_x, y+3*s_y) is reachable.
- soldier: May move one step in any of the 8 directions.
Additional rules:
- A move is illegal if the starting cell does not have a piece belonging to the current player, or if the move does not follow the moving rules, or if the destination is off the board or already occupied by one of the player’s own pieces.
- If the destination cell contains an opponent's piece, that piece is captured (removed from the board).
- The goal is to capture (i.e. remove from game) the opponent's
captain
. Once a captain is captured, the game ends immediately. - A board is said to be in a check (or "jamming") state if, after a move, the moving side has at least one legal move that could capture the opponent's captain in the next step.
The game starts with red moving first. The initial board configuration is fixed as follows:
- Red pieces:
- captain at (10,5)
- guard at (10,4) and (10,6)
- elephant at (10,3) and (10,7)
- horse at (10,2) and (10,8)
- car at (10,1) and (10,9)
- duck at (8,5)
- soldier at (7,1), (7,3), (7,5), (7,7) and (7,9)
- Blue pieces:
- captain at (1,5)
- guard at (1,4) and (1,6)
- elephant at (1,3) and (1,7)
- horse at (1,2) and (1,8)
- car at (1,1) and (1,9)
- duck at (3,5)
- soldier at (4,1), (4,3), (4,5), (4,7) and (4,9)
You are given a sequence of move operations. Each operation describes an attempt by the current player to move the piece from a source cell (x₁, y₁) to a destination cell (x₂, y₂). If the move is legal, you must update the board accordingly and output the following information in one line:
- The type of the moved piece.
- If an opponent’s piece was captured, output its type; otherwise output
None
. - Whether the board is in a check state (
Yes
orNo
). - The game status – output
GameOver
if the move captured the opponent’s captain, otherwise outputContinue
.
If an operation is illegal (because the chosen cell does not contain one of the current player’s pieces, the move isn’t according to the rules, or the game is already over), it is ignored. The current player does not change until a legal move is encountered.
inputFormat
The first line of input contains an integer n, the number of move operations. Each of the following n lines contains four integers: x₁ y₁ x₂ y₂, representing a move from (x₁, y₁) to (x₂, y₂). All coordinates satisfy 1 ≤ x ≤ 10 and 1 ≤ y ≤ 9.
outputFormat
For each legal move performed (in order), output one line with four space‐separated items:
- Moved piece type
- Captured piece type (or None if no capture)
- Check status: Yes if a legal move exists (by the moving side) that can capture the opponent's captain in the current board, otherwise No
- Game status: GameOver if the opponent's captain has been captured, otherwise Continue
sample
4
10 5 9 5
1 5 2 5
9 5 8 5
10 2 8 3
captain None No Continue
captain None No Continue
horse None No Continue
</p>