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

俺叫大飞,用DFS要跑32MS,汗,望大牛指点。

Posted by qifeifei at 2010-08-04 14:59:54 on Problem 1166
void dfs(int d)
{
	int m,n;
	if(f=='y') return;
	if(d>=10) 
	{
		e[0]=w[1]+w[2]+w[4];
		e[1]=w[1]+w[2]+w[3]+w[5];
		e[2]=w[2]+w[3]+w[6];
		e[3]=w[1]+w[4]+w[5]+w[7];
		e[4]=w[1]+w[3]+w[5]+w[7]+w[9];
		e[5]=w[3]+w[5]+w[6]+w[9];
		e[6]=w[4]+w[7]+w[8];
		e[7]=w[5]+w[7]+w[8]+w[9];
		e[8]=w[6]+w[8]+w[9];
		for(m=0;m<9;m++)
			if((e[m]+clock[m/3][m%3])%4!=0)  return;
		for(m=1;m<10;m++)
			for(n=0;n<w[m];n++)
				cout<<m<<' ';
		f='y';
		return;
	}
	for(m=0;m<4;m++)
	{
		flag[d]=m;
		dfs(d+1);
	}
}

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