Skip to content

Commit

Permalink
코테준비
Browse files Browse the repository at this point in the history
  • Loading branch information
sunho1999 committed May 29, 2024
1 parent 83c2cab commit d6ac3e0
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Baekjoon_file/5430.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import sys
from collections import deque

input = sys.stdin.readline

t = int(input())


answer = []
for _ in range(t):
p = input().strip()
n = int(input().strip())
arr = list(input().strip()[1:-1].split(","))
q = deque(arr)
reverse = 0
error = 0
if n == 0:
q = []

for i in p:
if i == "R":
reverse = not reverse
else:
if len(q) < 1:
answer.append("error")
error = 1
break
else:
if reverse:
q.pop()
else:
q.popleft()

if not error:
if reverse:
q.reverse()
answer.append("[" + ",".join(q) + "]")

for a in answer:
print(a)

0 comments on commit d6ac3e0

Please sign in to comment.