#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;
int main()
{
int a[30000],n,m=11000,data;
int l=0,r=m,i=0;
cin>>n;
string str;
for(int j=1;j<=n;j++)
{
cin>>str;
if(str=="LIN")
{
cin>>data;
a[--l]=data;
}
else if(str=="RIN")
{
cin>>data;
a[++r]=data;
}
else if(str=="LOUT")
{
if(l!=m)
cout<<a[l++]<<endl;
//cout<<l<<endl;
else
cout<<j<<" "<<"ERROR"<<endl;
}
else if(str=="ROUT")
{
if(r!=m)
cout<<a[r--]<<endl;
else
cout<<j<<" "<<"ERROR"<<endl;
}
}
return 0;
}
SDUT 双向队列(队列)
最新推荐文章于 2020-11-13 19:41:38 发布