https://www.acmicpc.net/problem/5430
https://www.acmicpc.net/board/view/87040 감사합니다
1
R
0
[]
----
출력 error
정답 []
import sys
from collections import deque
input = sys.stdin.readline
t = int(input())
for _ in range(t):
p = input().strip()
n = int(input())
direction = True
try:
nums = input().lstrip("[").rstrip("]\n")
if nums == "":
nums = []
else:
nums = deque(list(map(int, nums.split(","))))
for x in p:
if x=="R":
direction = not direction
elif x=="D":
if direction:
nums.popleft()
else:
nums.pop()
if not direction:
nums = list(nums)[::-1]
print("[", end="")
print(",".join(map(str,nums)), end="")
print("]")
except:
print("error")