#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 100010;
int q[N];
int hh, tt;
void init()
{
hh = 0, tt = -1;
}
int main()
{
int m;
cin >> m;
init();
string op;
int x;
while (m -- )
{
cin >> op;
if (op == "push")
{
cin >> x;
q[++ tt] = x;
}
if (op == "pop")
{
hh ++;
}
if (op == "empty")
{
cout << (hh > tt ? "YES" : "NO") << endl;
}
if (op == "query")
{
cout << q[hh] << endl;
}
}
}
算法基础课:模拟队列
最新推荐文章于 2024-07-19 19:11:19 发布