import sys
input = sys.stdin.readline
N = int(input().rstrip())
graph = dict()
for _ in range(N):
p, chl, chr = input().split()
graph[p] = (chl, chr)
def preorder(node, arr):
arr.append(node)
if graph[node][0] != ".":
arr = preorder(graph[node][0], arr)
if graph[node][1] != ".":
arr = preorder(graph[node][1], arr)
return arr
def inorder(node, arr):
if graph[node][0] != ".":
arr = inorder(graph[node][0], arr)
arr.append(node)
if graph[node][1] != ".":
arr = inorder(graph[node][1], arr)
return arr
def postorder(node, arr):
if graph[node][0] != ".":
arr = postorder(graph[node][0], arr)
if graph[node][1] != ".":
arr = postorder(graph[node][1], arr)
arr.append(node)
return arr
for e in preorder("A", []):
print(e, end="")
print()
for e in inorder("A", []):
print(e, end="")
print()
for e in postorder("A", []):
print(e, end="")
#
처리를 안해줘서 틀렸다. #
처리를 해줬지만 테스트케이스 12번이 계속 틀렸는데 이유를 알 수 없어 질문 하기의 다른 분이 작성하신 것을 보고 "A#"을 "a" 로 새로운 문자열을 변환해주고 풀었더니 정답이었다파이썬 find(), count()
해당 문자열이 기준 문자열에 있는지 확인하고 인덱스를 반환한다
없을 시에는 -1을 반환한다
string = "ABC"
basic = "1ABC"
print(basic.find(string)) # 1
해당 문자열이 몇 개 있는지 세준다
string = "ABC"
basic = "ABCABC"
print(basic.count(string)) # 2