AcWing 829. 模拟队列
原题链接
简单
作者:
xi.xi
,
2025-04-09 17:53:08
· 四川
,
所有人可见
,
阅读 2
#include <iostream>
using namespace std;
const int N = 100010;
int q[N];
int hh = 0;
int tt = -1;
int m;
string s;
void push(int x){
q[++tt] = x;
}
void pop(){
hh++;
}
void empty(){
if(tt >= hh) cout << "NO" << endl;
else cout << "YES" << endl;
}
void query (){
cout << q[hh] << endl;
}
int main(){
cin >> m;
while(m--){
cin >> s;
if(s == "push"){
int x;
cin >> x;
push(x);
}
if(s == "pop"){
pop();
}
if(s == "empty"){
empty();
}
if(s == "query"){
query();
}
}
}