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;
}
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;
}
相关文章推荐
- 【BZOJ】3403: [Usaco2009 Open]Cow Line 直线上的牛(模拟)
- bzoj3403[Usaco2009 Open]Cow Line 直线上的牛
- bzoj 3403: [Usaco2009 Open]Cow Line 直线上的牛 暴力
- BZOJ 3403: [Usaco2009 Open]Cow Line 直线上的牛( deque )
- bzoj 3403: [Usaco2009 Open]Cow Line 直线上的牛
- bzoj3403[Usaco2009 Open]Cow Line 直线上的牛
- 3403: [Usaco2009 Open]Cow Line 直线上的牛
- 3403: [Usaco2009 Open]Cow Line 直线上的牛
- bzoj3403: [Usaco2009 Open]Cow Line 直线上的牛
- bzoj3403 [Usaco2009 Open]Cow Line 直线上的牛
- BZOJ3403: [Usaco2009 Open]Cow Line 直线上的牛
- 【BZOJ1575】【USACO 2009 OPEN】 气象牛Baric
- BZOJ1572 [Usaco2009 Open]工作安排Job
- bzoj3404 [Usaco2009 Open]Cow Digit Game又见数字游戏
- bzoj 3383: [Usaco2004 Open]Cave Cows 4 洞穴里的牛之四
- bzoj3405:[Usaco2009 Open]Grazing2 移动牛棚
- BZOJ 1571: [Usaco2009 Open]滑雪课Ski
- bzoj1572 [Usaco2009 Open]工作安排Job【贪心 堆】
- [bzoj1572][Usaco2009 Open]工作安排Job_贪心_堆
- 【BZOJ】【3404】【USACO2009 Open】Cow Digit Game又见数字游戏