1.模拟队列
#include<iostream>
using namespace std;
const int N = 1e5 + 10;
int q[N];
int main() {
int n;
cin >> n;
int hh = 0, tt = 0;
while (n--)
{
string op;
int x;
cin >> op;
if (op == "push")
{
cin >> x;
q[tt++] = x;
}
else if (op == "pop") {
hh++;
} else if (op == "empty") {
if (hh < tt) puts("NO");
else puts("YES");
} else {
cout << q[hh] << endl;
}
}
}
/*
#include<iostream>
using namespace std;
const int N=1e5+10;
int x;
int q[N];
int hh=0, tt=-1; //队头hh=0,队尾tt=-1
int main()
{
int n;
cin>>n;
while(n--){
string op;
cin>>op;
//hh=[0],tt=[1]
if(op=="push") //插入元素,下标从[1]开始
{
cin>>x;
q[++tt]=x;
}
else if(op=="pop") //弹出队头
{
hh++;
}
else if(op=="empty")//判断是否为空 hh>tt空
{
if(hh<=tt) puts("NO");
else puts("YES");
}
else //队头元素
{
cout<<q[hh]<<endl;
}
}
}
*/