Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
感觉你超时就是因为计算步数太多了吧。。每次都算那么多种情况这题卡的又严In Reply To:你的愣是没看懂||=.=。。你看看我的吧。 Posted by:ACM06060 at 2007-10-12 13:06:31 > 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator