// UVa1343 The Rotation Game
// Rujia Liu
// This solutions uses IDA* instead of BFS described in the book, because it's shorter 8-)
// It's shorter because no need for lookup tables and "automatically" lexicographically smallest solution.
#include<cstdio>
#include<algorithm>
using namespace std;
// 每个格子对应的index
/*
00 01
02 03
04 05 06 07 08 09 10
11 12
13 14 15 16 17 18 19
20 21
22 23
*/
// lines E~H are computed with the help of rev[]
// 4条 8个方向 7个数
int line[8][7]={
{ 0, 2, 6,11,15,20,22}, // A
{ 1, 3, 8,12,17,21,23}, // B
{10, 9, 8, 7, 6, 5, 4}, // C
{19,18,17,16,15,14,13}, // D
};
//每个方向对应的反方向
const int rev[8] = {5, 4, 7, 6, 1, 0, 3, 2}; // reverse lines of each line
// center squares
// 题目要求的八个中心格子对应的index
const int center[8] = {6, 7, 8, 11, 12, 15, 16, 17};
// 总共24个数
int a[24];
// ans记录每步的移动方向(A、B、C...H)
char ans[1000];
//八个中心格子是不是都相等
bool is_final() {