#P1225. 黑白棋游戏
黑白棋游戏
Description
The board of the black-and-white chess game consists of a grid. Each square contains piece, with white pieces and black pieces in total. Every arrangement of these pieces constitutes a game state. Two squares that share a common edge are called adjacent squares. A square can have at most adjacent squares. In each move, you may swap the pieces in any two adjacent squares. Given an initial game state and a target game state, write a program to compute the shortest sequence of moves that transforms the initial state into the target state.
Input Format
The input consists of lines. The first lines describe the initial game state, and the last lines describe the target game state. Each line contains numbers indicating the colors of the pieces in that row. "0" denotes a white piece; "1" denotes a black piece.
Output Format
Output the number of moves on the first line. Then output lines, each containing numbers that represent the positions of the two adjacent squares whose pieces are swapped in that move. For example, abcd denotes swapping the piece at with the piece at .
1111
0000
1110
0010
1010
0101
1010
0101
4
1222
1424
3242
4344
Hint
SPJ provided by @zhouyonglong.
Translated by ChatGPT 5
京公网安备 11011102002149号