解题思路
光标前后各用一个栈维护即可
代码
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 1e6 + 5;
struct Stack {
int n, s[maxn];
void init() { n = 0; }
bool empty() { return n == 0; }
void push(int x) { s[n++] = x; }