比赛 20120417 评测结果 RRRRRRRRRRRRRRRRR
题目名称 牛棚的灯 最终得分 0
用户昵称 feng 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2012-04-17 10:43:09
显示代码纯文本
#include<fstream>
#include<cstdio>
#include<memory.h>
#include<deque>
#include<iterator>
using namespace std;
deque<int>c;
int i,j,k,n,m,p;
char x,y;
string s;
int main()
{
	ifstream fin("cline.in");
	ofstream fout("cline.out");
	fin>>n;
	p=0;
	for (i=1;i<=n;i++)
	{
		fin>>x>>y;
		if (x=='D')
		{
			fin>>k;
		}
		if(x=='A' && y=='L')             
			c.push_front(++p);         
		if(x=='A' && y=='R')             
			c.push_back(++p);
		
		
		if(x=='D' && y=='L')             
			for(j=1;j<=k;j++)                 
				c.pop_front();         
		if(x=='D' && y=='R')             
			for(j=1;j<=k;j++)                 
				c.pop_back(); 
		
		
		/*if (x=='D' && y=='L')
			for (j=1;j<=k;j++);
				c.pop_front();
		if (x=='D' && y=='R')
			for (j=1;j<=k;j++)
				c.pop_back();*/
	}
	deque<int>::iterator iter;
	for (iter=c.begin();iter!=c.end();iter++)
	{
		fout<<*iter<<endl;
	}
	fin.close();
	fout.close();
	return 0;
}