您的位置:首页 > 运维架构

BZOJ 3403: [Usaco2009 Open]Cow Line 直线上的牛(模拟)

2014-07-10 10:15 316 查看
直接双端队列模拟,完了= =

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: