#57. 模拟队列

模拟队列

问题描述

你需要实现一个队列,初始时队列为空。有 mm 组查询,每次查询为以下四种操作之一:

  • push x:向队尾插入一个正整数 xx
  • pop:删除队首元素,若此时队列为空,则不做任何操作。
  • empty:判断队列是否为空,若为空输出 YES,否则输出 NO
  • query:输出队首元素,若队列为空则输出 empty

输入格式

第一行输入一个正整数 mm(1m105)(1\le m\le 10^5)

接下来 mm 行,每行输入一种操作,对于 emptyquery,需要有对应的输出。push xxx 范围 (1x105)( 1\le x\le 10^5)

输出格式

对于 emptyquery 操作,按照题目要求输出。

样例输入

11
push 5
query
push 6
pop
pop
query
pop
empty
push 4
query
empty

样例输出

5
empty
YES
4
NO