F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Eleven puzzle

Time Limit: 20000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 935    Accepted Submission(s): 270


Problem Description
Partychen invents a new game named ¡°Eleven Puzzle¡± .Just like the classic game ¡°Eight Puzzle¡±,but there some difference between them:The shape of the board is different and there are two empty tiles.

The tile in black means it¡¯s empty

Each step you can move only one tile.
Here comes the problem.How many steps at least it required to done the game.
 

Input
The first line of input contains one integer specifying the number of test cases to follow.
Every case contains five lines to describe the initial status of the board. 0 means empty.

It¡¯s confirmed that the board is legal.
 

Output
Output one line for each testcase.Contain an integer denotes the minimum step(s) it need to complete the game.Or ¡°No solution!¡± if it¡¯s impossible to complete the game within 20 steps.
 

Sample Input
3 2 1 0 3 4 5 6 7 8 9 0 11 10 0 1 2 3 4 5 6 7 8 9 10 11 0 0 11 10 9 8 7 6 5 4 3 2 1 0
 

Sample Output
2 0 No solution!
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 22:16:19, Gzip enabled