白俊.10845番です.草を切る


白俊.10845番です.草を切る
質問リンクhttps://www.acmicpc.net/problem/10845
import sys
input = sys.stdin.readline

from collections import deque

n = int(input())

q = deque()

for _ in range(n):
    command = input().split()

    if "push" == command[0]:
        q.append(command[1])
    elif "front" == command[0]:
        if q:
            print(q[0])
        else:
            print(-1)
    elif "back" == command[0]:
        if q:
            print(q[-1])
        else:
            print(-1)
    elif "empty" == command[0]:
        if q:
            print(0)
        else:
            print(1)
    elif "pop" == command[0]:
        if q:
            print(q.popleft())
        else:
            print(-1)
    elif "size" == command[0]:
        print(len(q))