题解 | 【模板】队列操作
【模板】队列操作
https://www.nowcoder.com/practice/1137c8f6ffac4d5d94cc1b0cb08723f9
n = int(input())
from collections import deque
q = deque()
for _ in range(n):
a = input().split()
if a[0] == '1':
q.append(int(a[1]))
elif a[0] == '2':
if q:
q.popleft()
else:
print('ERR_CANNOT_POP')
elif a[0] == '3':
if q:
print(q[0])
else:
print('ERR_CANNOT_QUERY')
elif a[0] == '4':
print(len(q))
格力公司福利 319人发布