BZOJ 3403: [Usaco2009 Open]Cow Line 直线上的牛(模拟)
直接双端队列模拟,完了= =
CODE:
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<queue>
using namespace std;
int n,sum;
char s[2],st[2];
deque<int> d;
int main(){
scanf("%d",&n);
for (int i=1;i<=n;i++){
scanf("%s%s",s,st);
if (s[0]=='A'){
sum++;
if (st[0]=='L'){
d.push_front(sum);
}else {
d.push_back(sum);
}
}else {
int x;
scanf("%d",&x);
if (st[0]=='L'){
for (int j=1;j<=x;j++) d.pop_front();
}else{
for (int j=1;j<=x;j++) d.pop_back();
}
}
}
while (!d.empty()){
printf("%d\n",d.front());
d.pop_front();
}
return 0;
}