#P4289. [HAOI2008] 移动玩具

    ID: 3224 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>2008河南各省省选哈希,HASH进制队列

[HAOI2008] 移动玩具

Description

In a 4×44 \times 4 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 11 or 00. Here, 11 means a toy is placed in the cell, and 00 means the cell is empty. Then there is a blank line. The next four lines describe the target state, each line containing four numbers 11 or 00, 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