| 记录编号 | 
        43380 | 
        评测结果 | 
        AAAAAAAAAAAAAAAAAAAA | 
    
    
        | 题目名称 | 
        1126.[NOIP 2010冲刺七]翻转游戏 | 
        最终得分 | 
        100 | 
            
    
    
        | 用户昵称 | 
         QhelDIV | 
        是否通过 | 
        通过 | 
    
    
        | 代码语言 | 
        C++ | 
        运行时间 | 
        0.039 s  | 
    
    
        | 提交时间 | 
        2012-10-10 08:41:09 | 
        内存使用 | 
        3.12 MiB  | 
        
    
    
    
    		显示代码纯文本
		
		#include <fstream>
#include <cstdlib>
using namespace std;
ifstream fin("flip.in");
ofstream fout("flip.out");
long long sta=0,num,Min=~0u>>1;
void Initialize()
{
int i,j;
char A[5][5];
	for(i=1;i<=4;i++)
		for(j=1;j<=4;j++)
		{
			fin>>A[i][j];
			sta<<=1;
			sta+=(A[i][j]=='b'?false:true);
		}
}
void Change(int pos)
{
//itself
	sta=sta^(1<<(pos-1));
//up
	if(pos-4>0)
		sta=sta^(1<<(pos-5));
//left
	if(pos%4!=0)
		sta=sta^(1<<pos);
//down
	if(pos+4<16)
		sta=sta^(1<<(pos+3));
//right
	if(pos%4!=1)
		sta=sta^(1<<(pos-2));
}
bool Check()
{
	if(sta==65535 || sta==0)
		return true;
	return false;
}
void DFS(int pos)
{
int temp=sta;
	if(pos==17)
	{
		if(Check())
			Min=min(Min,num);
		return;
	}
	num++;
	Change(pos);
	DFS(pos+1);
	sta=temp;
	num--;
	
	DFS(pos+1);
}
int main()
{
	Initialize();
	
	DFS(1);
	
	if(Min==~0u>>1)
		fout<<"Impossible"<<endl;
	else
		fout<<Min<<endl;
	
	fin.close();
	fout.close();
	return 0;
}