Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions heeheej/week31/BOJ_12919_A와_B_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# A와 B 2
# S에서 T를 만드는게 아니라, T에서 S를 만드는 방식으로 접근
# 108080kb, 108ms

import sys

sys.stdin = open("input.txt", "r")
input = sys.stdin.readline

S = input().rstrip()
T = input().rstrip()

def task(t):
if S == t:
print(1)
exit()
elif len(t) <= len(S):
return

if t[-1] == 'A':
task(t[:len(t)-1])
if t[0] == 'B':
t = t[::-1]
t = t[:len(t)-1]
task(t)

task(T)
print(0)