#P4289. [HAOI2008] 移动玩具
[HAOI2008] 移动玩具
Description
In a grid, several identical toys are placed. Someone wants to rearrange these toys into his ideal state. Each move can only shift a toy up, down, left, or right, and the destination position must be empty. Please transform the initial state into the target state using the fewest number of moves.
Input Format
The first four lines describe the initial state of the toys, each line containing four numbers or . Here, means a toy is placed in the cell, and means the cell is empty. Then there is a blank line. The next four lines describe the target state, each line containing four numbers or , with the same meaning as above.
Output Format
Output a single integer: the minimum number of moves required.
1111
0000
1110
0010
1010
0101
1010
0101
4
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号