队列:先进先出
#include<iostream>
using namespace std;
const int N = 100010;
int q[N],hh,tt = -1; //hh表示队头,tt表示队尾,在队尾插入元素,在队头弹出元素
char op[5];
//从队尾插入
q[ ++ tt] = x;
//弹出队头
hh ++;
//判断队列是否为空
if(hh <= tt) not empty;
else empty;
//输出队头
cout << q[hh];
//同理可以输出队尾
cout << q[tt];
int main(){
int n,x;
cin >> n;
while(n -- ){
cin >> op;
if(op[2] == 's') {
cin >> x;
q[ ++ tt] = x; //从队尾插入
}
else if(op[1] == 'o') hh ++ ; //从队头弹出
else if(op[1] == 'm') {
if(hh <= tt) cout << "NO" <<endl; //如果队头小于队尾,则非空
else cout << "YES" <<endl;
}
else cout << q[hh] <<endl; //输出队头
}
return 0;
}