-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10845.py
More file actions
40 lines (32 loc) · 812 Bytes
/
10845.py
File metadata and controls
40 lines (32 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from collections import deque
import sys
N = int(sys.stdin.readline())
queue = deque()
for _ in range(N):
order_input = list(sys.stdin.readline().split())
order = order_input[0]
if order == "push":
number = order_input[1]
queue.append(number)
elif order == "pop":
if queue:
print(queue.popleft())
else:
print(-1)
elif order == "size":
print(len(queue))
elif order == "empty":
if queue:
print(0)
else:
print(1)
elif order == "front":
if queue:
print(queue[0])
else:
print(-1)
elif order == "back":
if queue:
print(queue[-1])
else:
print(-1)