NAJEP - Easy Puzzle
Boltu loves puzzle very much. He solves different types of puzzle problems in different online judges. Sometimes he teaches his small brother Gultu how to solve puzzle. But Gultu is not very good at this. One day Boltu made a puzzle for Gultu. It’s a number puzzle. A board contains N rows & M columns. Each of the cells of this board contains a square shaped disk. Each disk contains a random number between 0 to (N*M)-1. These numbered disks are placed randomly. You have to put these disks in ascending order. Moving these disks always maintains a rule. You must put off two disks at a time & place them. Gultu says that it seems too easy. Boltu says yes it is. But you have to solve it in minimum move. After sometime he did it & very excited. If Gultucan solve it then you must do that.
For 3x3 board.it needs minimum 6 moves to do so.
0 |
7 |
8 |
1 |
2 |
3 |
4 |
5 |
6 |
TO
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
Input
Input starts with an integer t<=100. Each input takes two integers N<=100& M<=100 where N represents row & M represents column. Then input N*M integers where each row contains M numbers.
Output
For each input the output line shows case number and minimum moves needed to solve this.
Sample:
Input |
Output |
2 |
Case 1: 6
|
Authored By: Tanvir Hasan Anick
hide comments
|
Francky:
2014-11-11 01:37:29
@psetter : you should keep an eye on your recent problems and answer psolver questions.
|
|
Min_25:
2014-11-04 15:18:53
This problem is broken:
|
Added by: | Najmuzzaman |
Date: | 2014-10-25 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |