forked from tony9402/baekjoon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
37 lines (35 loc) · 857 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/89f5e4e54afb441bbf218b5e68a4160d
import sys
from collections import deque
def input():
return sys.stdin.readline().rstrip()
N = int(input())
queue = deque()
for i in range(N):
command = input().split()
if command[0] == "push":
queue.append(command[1])
elif command[0] == "pop":
if queue:
print(queue.popleft())
else:
print(-1)
elif command[0] == "size":
print(len(queue))
elif command[0] == "empty":
if not queue:
print(1)
else:
print(0)
elif command[0] == "front":
if queue:
print(queue[0])
else:
print(-1)
elif command[0] == "back":
if queue:
print(queue[-1])
else:
print(-1)