forked from tony9402/baekjoon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
37 lines (35 loc) · 825 Bytes
/
main.py
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
# Authored by : gusdn3477
# Co-authored by : -
# Link : http://boj.kr/6bf4491116ff480fab750a65591c134e
import sys
from collections import deque
def input():
return sys.stdin.readline().rstrip()
queue = deque()
N = int(input())
for i in range(N):
com = input().split()
if com[0] == 'push':
queue.append(com[1])
elif com[0] == 'pop':
if queue:
print(queue.popleft())
else:
print(-1)
elif com[0] == 'size':
print(len(queue))
elif com[0] == 'front':
if queue:
print(queue[0])
else:
print(-1)
elif com[0] == 'back':
if queue:
print(queue[-1])
else:
print(-1)
elif com[0] == 'empty':
if not queue:
print(1)
else:
print(0)