Algorithm/noj.am
[Python] 백준 10845번 - 큐
SweetDev
2021. 7. 14. 16:29
# 1722 순열의 순서
# 10845 큐
N = int(input())
queue = []
for i in range(N):
command = input()
if command.__contains__("push"):
queue.append(command[-1])
elif command.__contains__("pop"):
if len(queue) != 0:
val = queue.pop(0)
print(val)
else:
print("-1")
elif command.__contains__("size"):
print(len(queue))
elif command.__contains__("empty"):
if len(queue) == 0:
print("1")
else:
print("0")
elif command.__contains__("front"):
if len(queue) == 0:
print("-1")
else:
print(queue[0])
elif command.__contains__("back"):
if len(queue) == 0:
print("-1")
else:
print(queue[-1])