比赛 20120416 评测结果 AAAAAAAAAA
题目名称 奶牛队列 最终得分 100
用户昵称 song 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2012-04-16 09:14:38
显示代码纯文本
#include<cstdio>
#include<iostream>
using namespace std;
int aa(int a,int b);
int bb(int x,int y);
int ss[200001],ll=100000,rr=100001,sh=1,a=0;
char kk=0;
int main()
{
	freopen("cline.in","r",stdin);
	freopen("cline.out","w",stdout);
	cin>>a;
	for(int i=0;i<a;i++)
	{
		cin>>kk;
		char pp=0;
		if(kk=='A')
		{
			cin>>pp;
			if(pp=='L')
			{
				aa(0,sh);
				sh++;
			}
			else
			    if(pp=='R')
			    {
				    aa(1,sh);
				    sh++;
			    }
		}
		if(kk=='D')
		{
			int o=0;
			cin>>pp;
			cin>>o;
			if(pp=='L')
			{
				bb(0,o);
			}
			else
				if(pp='R')
				{
					bb(1,o);
				}
		}
	}
	for(int i=ll+1;i<rr;i++)
	{
		cout<<ss[i]<<endl;
	}
}
int aa(int a,int b)
{
	if(a==0)
	{
		ss[ll]=b;
		ll--;
	}
	if(a==1)
	{
		ss[rr]=b;
		rr++;
	}
}
int bb(int x,int y)
{
	if(x==0)
	{
		ll+=y;
	}
	if(x==1)
	{
		rr-=y;
	}
}