From e15551bf38d644aa78a68378e84f80ad800f3c5a Mon Sep 17 00:00:00 2001 From: H0ngJu Date: Tue, 14 May 2024 16:57:23 +0900 Subject: [PATCH] 2024-05-14 --- H0ngJu/README.md | 1 + .../A\354\231\200 B.py" | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 "H0ngJu/\352\267\270\353\246\254\353\224\224/A\354\231\200 B.py" diff --git a/H0ngJu/README.md b/H0ngJu/README.md index 3d9e3ddc..517e2252 100644 --- a/H0ngJu/README.md +++ b/H0ngJu/README.md @@ -16,5 +16,6 @@ | 12차시 | 2024.04.09 | DFS | [ABCDE](https://www.acmicpc.net/problem/13023) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/180 | | 13차시 | 2024.05.06 | 완전탐색 | [리모컨](https://www.acmicpc.net/problem/1107) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/181 | | 14차시 | 2024.05.09 | DFS | [치킨배달](https://www.acmicpc.net/problem/15686) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/183 | +| 15차시 | 2024.05.14 | 그리디 | [A와 B](https://www.acmicpc.net/problem/12904) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/188 | --- diff --git "a/H0ngJu/\352\267\270\353\246\254\353\224\224/A\354\231\200 B.py" "b/H0ngJu/\352\267\270\353\246\254\353\224\224/A\354\231\200 B.py" new file mode 100644 index 00000000..f95e7918 --- /dev/null +++ "b/H0ngJu/\352\267\270\353\246\254\353\224\224/A\354\231\200 B.py" @@ -0,0 +1,27 @@ +import sys +sys.setrecursionlimit(10**6) + +def input(): return sys.stdin.readline().rstrip() + +S = list(input()) +T = list(input()) + +def solution(cur, target): + if len(cur) == len(target): # len(cur) == len(target) + if cur == target: + return 1 + else: return 0 + + elif len(cur) < len(target): # len(cur) < len(target) + if target[-1] == "A": + target.pop() + return solution(cur, target) + else: + target.pop() + target = target[::-1] + return solution(cur, target) + + else: # len(cur) > len(target) + return 0 + +print(solution(S, T)) \ No newline at end of file