题目链接:https://codeforces.com/contest/670/problem/E 题意: 给出一个已经匹配的括号串,给出起始的光标位置(光标总是指向某个括号). 有如下操作: 1.往左移动一下光标: 2.往左移动一下光标: 3.删除当前光标指向的括号,以及和它匹配的那个括号,以及这两个括号之间的所有括号. 要求你给出在做完所有操作后的括号串. 题解: 用对顶栈进行模拟.由于删除是不可逆的,因此删除的总时间复杂度为 $O(n)$,因此所有 $m$ 次操作的总时间复杂度为 $O(n…
E. Correct Bracket Sequence Editor time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Recently Polycarp started to develop a text editor that works only with correct bracket sequences (abbrev…
题目链接:https://codeforces.com/contest/670/problem/E 题意: 给出一个已经匹配的括号串,给出起始的光标位置(光标总是指向某个括号). 有如下操作: 1.往左移动一下光标: 2.往左移动一下光标: 3.删除当前光标指向的括号,以及和它匹配的那个括号,以及这两个括号之间的所有括号. 要求你给出在做完所有操作后的括号串. 题解: 用线段树维护,每个括号是否存在,存在记为 $1$,被删掉了记为 $0$. 然后我们只需要实现:①区间求和.②区间赋值.③根据 $…
题目链接:https://codeforces.com/contest/670/problem/E 题意: 给出一个已经匹配的括号串,给出起始的光标位置(光标总是指向某个括号). 有如下操作: 1.往左移动一下光标: 2.往左移动一下光标: 3.删除当前光标指向的括号,以及和它匹配的那个括号,以及这两个括号之间的所有括号. 要求你给出在做完所有操作后的括号串. 题解: 数组模拟链表即可,每种操作都是 $O(1)$ 的时间复杂度. 另外可以参看:本题的对顶栈做法.本题的线段树做法. AC代码: #…
链表,模拟. 写一个双向链表模拟一下过程. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #include<map> #include<set> #include&…
E. Correct Bracket Sequence Editor 题目连接: http://www.codeforces.com/contest/670/problem/E Description Recently Polycarp started to develop a text editor that works only with correct bracket sequences (abbreviated as CBS). Note that a bracket sequence…
E. Correct Bracket Sequence Editor   Recently Polycarp started to develop a text editor that works only with correct bracket sequences (abbreviated as CBS). Note that a bracket sequence is correct if it is possible to get a correct mathematical expre…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Recently Polycarp started to develop a text editor that works only with correct bracket sequences (abbreviated as CBS). Note that a bracket sequ…
Recently Polycarp started to develop a text editor that works only with correct bracket sequences (abbreviated as CBS). Note that a bracket sequence is correct if it is possible to get a correct mathematical expression by adding "+"-s and "…
题目链接: http://codeforces.com/contest/670/problem/E 题解: 用STL的list和stack模拟的,没想到跑的还挺快. 代码: #include<iostream> #include<cstdio> #include<cstring> #include<map> #include<list> #include<stack> using namespace std; + ; const in…