Notice
Recent Posts
Recent Comments
Link
목록12919 (1)
나의 개발일지
문제 : https://www.acmicpc.net/problem/12919 dfs 🔑 마지막이 A일 때, 처음이 B일 때 t[-1]이 "A"일 때 마지막 "A"빼고 재귀 호출 t[0]이 "B"일 때 뒤집은 후 마지막 "B"빼고 재귀 호출 각각 if 조건으로 두 가지 분기로 나눈다. s = input() t = input() def dfs(t): if len(s) == len(t): if s == t: print(1) exit() else: return 0 if t[-1] == "A": dfs(t[:-1]) if t[0] == "B": dfs(t[::-1][:-1]) dfs(t) print(0)
백준
2023. 10. 3. 15:22