https://www.acmicpc.net/problem/1991
# 2023.01.02
import sys
input = sys.stdin.readline
n = int(input())
graph = {}
for i in range(n):
a, b, c = map(str, input().split())
graph[a]=(b, c)
def preorder(node):
if node!='.':
print(node, end="")
preorder(graph[node][0])
preorder(graph[node][1])
def inorder(node):
if node!='.':
inorder(graph[node][0])
print(node, end="")
inorder(graph[node][1])
def postorder(node):
if node!='.':
postorder(graph[node][0])
postorder(graph[node][1])
print(node, end="")
preorder('A')
print()
inorder('A')
print()
postorder('A')
'Problem Solving > BOJ' 카테고리의 다른 글
[DP] 11660 구간합구하기5 (1) | 2023.01.02 |
---|---|
[DP] 9465 스티커 (0) | 2023.01.02 |
[DP] 1932 정수 삼각형 (0) | 2023.01.02 |
[Divide and Conquer] 1629 곱셈 (0) | 2023.01.01 |
[DP] 1149 RGB거리 (0) | 2023.01.01 |