csu 1809 Parenthesis】的更多相关文章

Parenthesis Problem Description: Bobo has a balanced parenthesis sequence P=p1 p2-pn of length n and q questions. The i-th question is whether P remains balanced after pai and pbi swapped. Note that questions are individual so that they have no affec…
1809: Parenthesis Submit Description Bobo has a balanced parenthesis sequence P=p1 p2…pn of length n and q questions. The i-th question is whether P remains balanced after pai and pbi  swapped. Note that questions are individual so that they have no…
1809: Parenthesis Submit Page     Summary    Time Limit: 5 Sec     Memory Limit: 128 Mb     Submitted: 1500     Solved: 398 Description Bobo has a balanced parenthesis sequence P=p1 p2…pn of length n and q questions. The i-th question is whether P re…
题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1809 Bobo has a balanced parenthesis sequence P=p 1 p 2…p n of length n and q questions. The i-th question is whether P remains balanced after p ai and p bi  swapped. Note that questions are ind…
题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1809 题目大意: 给一个长度为N(N<=105)的合法括号序列.Q(Q<=105)个询问,每次交换x,y位置上的括号后这个序列是否还合法,询问之间不影响. 题目思路: [贪心] 首先可以肯定,交换相同的括号是不会有影响的.把后面的'('和前面的')'交换也不会有影响.所以只用考虑把前面'('和后面的')'交换 而这时要满足x,y之间的所有位置i不会存在,1~i个括号中左括号数少于右…
题目见此 分析,把'('当成1, ')'当成-1, 计算前缀和sum. 记交换括号左边的序号为u, 右边为v,讨论左右括号: 1.s[u] == '(' && s[v] == ')' 那么[u, v - 1]的前缀和会全部-2 2.s[u] == '(' && s[v] == '(' 显然 3.s[u] == ')' && s[v] == '(' 那么[u, v - 1]的前缀和会全部+2 4.s[u] == ')' && s[v] == '…
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1809 给定一串平衡的序列,要求交换两个位置之后,问其是否还平衡. 首先要注意到交换的是两个位置,这两个位置没有大小之分,所以要判断是否swap他们,保持相对大小 然后如果我们把'('当成是1,把')'当成是-1,那么序列平衡,那么前缀和就是0了. 然后考虑下交换的时候,如果就交换相同的字符,那么肯定是Yes了,如果是')' 和 '(',那么也是Yes 因为本来序列就是平衡的,现在这样交换,只不过…
1809: Parenthesis Description Bobo has a balanced parenthesis sequence P=p1 p2…pn of length n and q questions. The i-th question is whether P remains balanced after pai and pbi  swapped. Note that questions are individual so that they have no affect…
1809: Parenthesis Time Limit: 5 Sec     Memory Limit: 128 Mb     Submitted: 2291     Solved: 622 Description Bobo has a balanced parenthesis sequence P=p1 p2…pn of length n and q questions. The i-th question is whether P remains balanced after pai an…
原题链接 http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1809 Description Bobo has a balanced parenthesis sequence P=p1 p2…pn of length n and q questions. The i-th question is whether P remains balanced after pai and pbi  swapped. Note that questions ar…