Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

哪位高手帮忙看看错在哪里?谢谢了!

Posted by 042622 at 2006-08-12 12:03:59 on Problem 1166
#include<iostream>
using namespace std;

int cl[9],res[20],min=100,prin[20];
int count[10]={0};
int move[10][9]={{0},{1,1,0,1,1},{1,1,1},{0,1,1,0,1,1},{1,0,0,1,0,0,1},{0,1,0,1,1,1,0,1},
			{0,0,1,0,0,1,0,0,1},{0,0,0,1,1,0,1,1},{0,0,0,0,0,0,1,1,1},{0,0,0,0,1,1,0,1,1}};

void solve(int t,int op);

int main()
{
	int i;
	for(i=0;i<9;++i)
	{
		cin>>cl[i];
	}
	
	for(i=1;i<10;++i)
	{
		for(i=0;i<10;++i)
			count[i]=0;
		solve(0,i);
	}
	
	for(i=0;i<min;++i)
		cout<<prin[i]<<' ';
	
	return 0;
}

void solve(int t,int op)
{
	int i,temp[9];
	bool flag;
	
	if(t>30)
		return;
	
	for(i=0;i<9;++i)
		temp[i]=cl[i];
	
	count[op]++;
	res[t]=op;
	for(i=0;i<9;++i)
	{
		cl[i]=(cl[i]+move[op][i])%4;
	}
	
	for(flag=true,i=0;i<9;++i)
	{
		if(cl[i]!=0)
		{
			flag=false;
			break;
		}
	}
	
	if(flag && t+1<min)
	{
		for(i=0;i<=t;++i)
			prin[i]=res[i];
		min=t+1;
		count[op]--;
		for(i=0;i<9;++i)
			cl[i]=temp[i];
	}else	
	{
		for(i=op;i<10;++i)
		{
			if(count[i]<3)
				solve(t+1,i);
		}
	}
	
	count[op]--;
	for(i=0;i<9;++i)
		cl[i]=temp[i];
}



Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator