| 记录编号 | 
        42229 | 
        评测结果 | 
        AAAAAAAAAA | 
    
    
        | 题目名称 | 
        1073.轮回游戏 | 
        最终得分 | 
        100 | 
            
    
    
        | 用户昵称 | 
         苏轼 | 
        是否通过 | 
        通过 | 
    
    
        | 代码语言 | 
        C++ | 
        运行时间 | 
        0.715 s  | 
    
    
        | 提交时间 | 
        2012-09-17 20:53:55 | 
        内存使用 | 
        0.31 MiB  | 
        
    
    
    
    		显示代码纯文本
		
		#include<iostream>
#include<cstdio>
#include<cstdlib>
#include <algorithm>
using namespace std;
int q[24];
int w[20],biao;
int answer=0;
int ff[8]={6, 7, 8, 11, 12, 15, 16, 17};
int f[8][7]={{0,2,6,11,15,20,22},{1,3,8,12,17,21,23},{10,9,8,7,6,5,4},{19,18,17,16,15,14,13},{23,21,17,12,8,3,1},{22,20,15,11,6,2,0},{13,14,15,16,17,18,19},{4,5,6,7,8,9,10}};
int deep=0;
bool dfs(int x);
int tong()
{
	int a[3]={0};
	for (int i=0;i<8;i++)
	{
		a[q[ff[i]]-1]++;
	}
	return 8 - max(max(a[0], a[1]), a[2]);
}
bool dfs(int x)
{
	if (x>deep)
		return 0;
	for (int i=0;i<8;i++)
	{
		w[x]=i;
		int a;
		a=q[f[i][0]];
		for (int j=0;j<6;j++)
		{
			q[f[i][j]]=q[f[i][j+1]];
		}
		q[f[i][6]]=a;
		int aa;
		aa=tong();
		if (!aa||(aa+x<deep&&dfs(x+1)))
			return 1;
		a=q[f[i][6]];
		for (int j=6;j>0;j--)
		{
			q[f[i][j]]=q[f[i][j-1]];
		}
		q[f[i][0]]=a;
	}
	return 0;
}
int main()
{
    freopen ("rotationa.in","r",stdin);
    freopen ("rotationa.out","w",stdout);
    while (1)
    {
		deep=0;
        for (int i=0;i<24;i++)
        {
            cin>>q[i];
            if (q[i]==0)
                exit(0);
        }
        answer=0;
		if (!tong())
		{
			printf("No moves needed\n%d\n", q[6]);
			continue;
		}
		while (!dfs(0))
		{
			deep++;
		}
		for (int i=0;i<deep;i++)
		{
			char b;
			b='A';
			b+=w[i];
			cout<<b;
		}
		cout<<endl<<q[6]<<endl;
	}
	return 0;
}