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 能过, 注意下输出-1的特判就行

Posted by flywarrior at 2012-10-26 21:28:41 on Problem 1948
贴一下搜索部分
A表示最大一条边,B表示第二大的边。
面积_cal(A,B,C)是用的海伦公式

void dfs(int A , int B){
    if(flag[A][B]||B>A||A>sum/2) return;
    int C=sum-A-B;  flag[A][B]=1;
    if(A>=B&&B>=C){
        double temp=_cal(A,B,C);
        ans=max(ans,temp);
    }
    fr(i,0,n){
        if(vis[i]) continue;
        vis[i]=1;
        dfs(A+len[i],B);
        vis[i]=0;
    }
    fr(i,0,n){
        if(vis[i]) continue;
        vis[i]=1;
        dfs(A,B+len[i]);
        vis[i]=0;
    }
}

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