#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int N=5e5+10;
int q[N];
int hh=0,tt=-1;//hh头 tt尾
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int n;
cin>>n;
while(n--)
{
string s;
cin>>s;
if(s=="push")
{ int x;
cin>>x;
q[++tt]=x;
}
if(s=="empty")
{
if(tt>=hh) cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
if(s=="pop")
{
hh++;
}
if(s=="query")
{
cout<<q[hh]<<endl;
}
}
}
标签:cout,队列,tt,cin,long,int,hh,数组,模拟
From: https://blog.csdn.net/hui_le4/article/details/140110016