-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbj_18258.py
More file actions
36 lines (33 loc) · 871 Bytes
/
Copy pathbj_18258.py
File metadata and controls
36 lines (33 loc) · 871 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
import sys
from collections import deque
# sys.stdin = open("bj_18258_in.txt", 'r')
input = sys.stdin.readline
q = deque()
order_n = int(input())
for _ in range(order_n):
order = list(input().rstrip().split())
if len(order) >= 2:
q.append(order[1])
else:
if order[0] == 'front':
if len(q) <= 0:
print(-1)
else:
print(q[0])
elif order[0] =='back':
if len(q) <= 0:
print(-1)
else:
print(q[-1])
elif order[0] == 'size':
print(len(q))
elif order[0] == 'empty':
if len(q) <= 0:
print(1)
else:
print(0)
elif order[0] == 'pop':
if len(q) <= 0:
print(-1)
else:
print(q.popleft())