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+剪枝的方法做的,为什么会无限的TLE

Posted by 1176497071 at 2015-08-27 00:33:00 on Problem 1014
void judge(int dx,int sumt)
{
	if(sumt==sum/2)
	{
	    stop=true;
		flag=true;
		return;
	}
	if(stop) return;
	for (int i=dx;i>=1;i--)
	{
	    if(sumt>sum/2) return;
		if(coun[i]>=num[i]||num[i]==0) continue;
		if(stop) break;
		coun[i]++;
		judge(i,sumt+i);
		coun[i]--;
		if(stop) break;
	}
}

其中dx是上一次加入的值,sumt是累加的值,coun数组用于记录1~6背包动态物品的数目。

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