求一个括号序列的合法子串个数

dp[i]表示以i结尾的合法的括号序列个数html 维护一个栈,左括号push他的位置到栈中,右括号取出栈顶 dp[i] = dp[sta[top] - 1] + 1数组 而后对dp数组求和markdown int sta[MAXN * 10], top, ans[MAXN * 10]; ll Ans; char s[MAXN * 10]; int main() { in, s + 1; int
相关文章
相关标签/搜索