Skip to content

Commit

Permalink
solve : 10845 큐
Browse files Browse the repository at this point in the history
  • Loading branch information
wwan13 committed May 2, 2024
1 parent 4500775 commit bb24144
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions python/boj_10845.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import sys

input = sys.stdin.readline


def solution(n):
queue = []

for i in range(n):
cmd = sys.stdin.readline().split()

if cmd[0] == "push":
queue.insert(0, cmd[1])

elif cmd[0] == "pop":
if len(queue) != 0:
print(queue.pop())
else:
print(-1)

elif cmd[0] == "size":
print(len(queue))

elif cmd[0] == "empty":
if len(queue) == 0:
print(1)
else:
print(0)

elif cmd[0] == "front":
if len(queue) == 0:
print(-1)
else:
print(queue[len(queue) - 1])

elif cmd[0] == "back":
if len(queue) == 0:
print(-1)
else:
print(queue[0])


def display_result(answer):
print(answer)


def main():
n = int(input())
solution(n)


main()

0 comments on commit bb24144

Please sign in to comment.