diff --git a/froglike6/README.md b/froglike6/README.md index 90f5cd8..3e35a97 100644 --- a/froglike6/README.md +++ b/froglike6/README.md @@ -13,4 +13,5 @@ | 9차시 | 2025.04.30 | 기하학 | [평행사변형](https://www.acmicpc.net/problem/1064)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/34| | 10차시 | 2025.05.08 | 이분탐색 | [게임](https://www.acmicpc.net/problem/1072)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/42| | 11차시 | 2025.05.08 | 조합론 | [High Towers](https://www.acmicpc.net/problem/33785)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/43| + | 12차시 | 2025.05.11 | 자료 구조 | [AC](https://www.acmicpc.net/problem/5430)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/46| --- diff --git a/froglike6/data_structure/5430.py b/froglike6/data_structure/5430.py new file mode 100644 index 0000000..aabd578 --- /dev/null +++ b/froglike6/data_structure/5430.py @@ -0,0 +1,30 @@ +from collections import deque +import sys +input = sys.stdin.readline + +for _ in range(int(input())): + func = input().rstrip() + if int(input()) == 0: + arr = deque() + input() + else: + arr = deque(map(int, input()[1:-2].split(","))) + rev = False + err = False + for i in func: + if i == "R": + rev = not rev + else: + if not arr: + print("error") + err = True + break + elif rev: + arr.pop() + else: + arr.popleft() + + if not err: + if rev: + arr.reverse() + print(f"[{','.join(map(str, arr))}]") \ No newline at end of file