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 ACM06060 at 2007-10-12 13:06:31 on Problem 3056
In Reply To:偶滴潮湿代码 Posted by:cuiaoxiang at 2007-10-12 12:26:12
a,b表示段 [a,b]
迭代的时候每次加2不然就会手臂交叉了。。
int dfs (int a, int b)
{
    if (dp[a][b]!=-1) return dp[a][b];
    if (a>=b) return 0;
    
    int ret = 0;
    for (int i=a+1; i<=b; i+=2)
    {
        int buf = dfs(a+1, i-1)+dfs(i+1, b);
        if (arr[i]==arr[a]) buf++;
        if (buf>ret) ret=buf;    
    }    
    
    dp[a][b] = ret;
    return ret;
}   

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