Problem hidden
This problem was hidden by Editorial Board member probably because it has incorrect language version or invalid test data, or description of the problem is not clear.

Problem hidden on 2014-11-11 01:38:09 by Francky

NAJEP - Easy Puzzle

no tags 

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
3 3
0 7 8
1 2 3
4 5 6

3 3
0 5 6
3 2 1
4 7 8

Case 1: 6
Case 2: 3

 

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.
Problem hidden waiting for fix.

Min_25: 2014-11-04 15:18:53

This problem is broken:

Assertion failed:
- assert(scanf("%u", &T) == 1);
or assert(scanf("%u %u", &N, &M) == 2);
or assert(scanf("%u", &board[i][j]) == 1);

@Md. Najmuzzaman
Please check the I/O files.

Last edit: 2014-11-04 15:21:30

Added by:Najmuzzaman
Date:2014-10-25
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64