样例和第一个测试点的数据相同,我用的手写的 蒟蒻队列,样例过了,第一个点却WA了,说第一行输出了 4 ,求助
#include<bits/stdc++.h>
#define eps 0.0000005
#define int long long
#define mod 100005
#define reg register
#define N 1000100
using namespace std;
//char in[1 << 20] ,*ss = in,*tt = in;
//#define getchar() (tt == ss && (tt = (ss = in) + fread(in, 1, 1 << 20,stdin),ss == tt) ? EOF : *ss++)
inline int read(){
int x = 0, f = 1; char ch = getchar();
while(ch > '9' || ch < '0'){
if(ch == '-') f = -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9'){
x = (x << 3) + (x << 1) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
struct dequeue
{
int l = 1, r = 0, len = 0;
map<int, int> que;
inline void L_push(int x)
{
que[-- l] = x;
len = -~len;
}
inline void L_pop(int dis)
{
l += dis;
len -= dis;
}
inline void R_pop(int dis)
{
r -= dis;
len -= dis;
}
inline void R_push(int x)
{
que[++ r] = x;
len = -~len;
}
inline int size()
{
return len;
}
}q;
int n, x, tot;
char act, pos;
signed main() {
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
n = read(), act = getchar();
for(reg int i = 1;i <= n;i = -~i)
{
cin >> act >> pos;
if(act == 'A')
{
if(pos == 'L') q.L_push(++ tot);
else q.R_push(++ tot);
}
else
{
x = read();
if(pos == 'L') q.L_pop(x);
else q.R_pop(x);
}
}
while(q.l <= q.r)
{
printf("%d\n", q.que[q.l]);
q.l = -~ q.l;
}
return 0;
}