가오리의 코딩일기

[1406] 에디터 본문

Python/백준

[1406] 에디터

류경혜 2022. 8. 15. 05:00

import sys
string = list(input())
stringList = []
n = int(input())
for i in range(n):
    command = sys.stdin.readline().split()
    if command[0] == "L" and string:
        stringList.append(string.pop())
    elif command[0] == "D" and stringList:
        string.append(stringList.pop())
    elif command[0] == "B" and string:
        string.pop()
    elif command[0] == "P":
        string.append(command[1])

print("".join(string + list(reversed(stringList))))

 

'Python > 백준' 카테고리의 다른 글

[10451] 순열 사이클  (0) 2022.08.21
[11724] 연결 요소의 개수  (0) 2022.08.21
[1158] 요세푸스 문제  (0) 2022.08.15
[1850] 최대공약수  (0) 2022.08.15
[9613] GCD 합  (0) 2022.08.15