首页 > TAG信息列表 > POJ2955

POJ2955 Brackets

题目链接 题目 Description We give the following inductive definition of a “regular brackets” sequence:the empty sequence is a regular brackets sequence,if s is a regular brackets sequence, then (s) and [s] are regular brackets sequences, andif a and b are r

POJ2955 Brackets (区间DP)

很好的区间DP题。 需要注意第一种情况不管是否匹配,都要枚举k来更新答案,比如: “()()()”:dp[0][5]=dp[1][4]+2=4,枚举k,k=1时,dp[0][1]+dp[2][5]=6,最后取最大值6. 第一层d相当于“长度”的含义,第二层枚举i,j就可以用i+d表示,通过这种方式枚举区间左右端点。 1 #include<cstdio> 2 #include<c