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,怎么做二进制,我还没经验

Posted by sunmoonstar_love at 2005-08-11 11:47:46 on Problem 2547
In Reply To:要记录搜过的二进制状态。 Posted by:zhucheng at 2005-08-11 11:42:15
bool DFS(const int &depth, const double &l, const double &r)
{
    if(depth==n)
        return true;
    int i;
    for(i=1; i<=n; i++)
    {
        if(!data[i].visit)
        {
            if(l-data[i].left>=0 && r - data[i].right<=0)
            {
                data[i].visit = true;
                if(DFS(depth+1,l-data[i].left,r - data[i].right))
                {
                     printf("%d %d\n",data[i].loc,data[i].wei);
                     return true;
                 }    
                data[i].visit = false;
            }    
        }
    }
    return false;    
}  

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