USACO Open 2009 Silver :Cow Line

From BNUOJ

#Solution

#include<iostream>
#include<stdio.h>
#include<deque>
using namespace std;

int main()
{
std::ios::sync_with_stdio(false);
int t,co=0,n=-1;
cin>>t;deque<int>cows;
while(t–)
{
char a,s;
cin>>a;
if(a==’A’)
{
cin>>s;
co++;
if(s==’L’)
{
cows.push_front(co);
}
else if(s==’R’)
cows.push_back(co);
}
else{
cin>>s>>n;
if(s==’R’)
{
for(int i=0;i<n;i++)
cows.pop_back();
}
else
{

for(int i=0;i<n;i++)
cows.pop_front();
}
}
}
for(deque<int>::iterator it=cows.begin();it!=cows.end();it++)
printf(“%d\n”,*it);
}

Advertisements

About waprogramming

I am in CSE,from CUET
This entry was posted in Uncategorized and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s