数组模拟队列
#include <iostream>
using namespace std;
const int N = 1e6 + 10;
int q[N], hh, tt = -1; //hh表示队头,tt表示队尾
int main()
{
int m;
cin >> m;
while (m -- )
{
string op;
int x;
cin >> op;
if (op == "push")
{
cin >> x;
q[ ++ tt] = x;
}
else if (op == "pop") hh ++ ;
else if (op == "query") printf("%d\n", q[hh]);
else
{
if (hh > tt) printf("YES\n");
else printf("NO\n");
}
}
return 0;
}