Skip to content

Commit f0c844a

Browse files
author
hangyeol
committed
113차 2번 문제풀이
1 parent d1301ac commit f0c844a

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
import sys
22
from collections import defaultdict
33

4-
54
def main():
65
input = sys.stdin.readline
76
N = int(input())
87

9-
graph = defaultdict(list)
8+
graph = defaultdict(dict)
109

1110
for _ in range(N):
12-
food = list(map(str, input().strip().split()))
11+
food = input().strip().split()
1312
K = int(food[0])
1413
foods = food[1:]
1514

1615
current_node = graph
17-
1816
for f in foods:
1917
if f not in current_node:
20-
current_node[f] = defaultdict(list)
18+
current_node[f] = defaultdict(dict)
2119
current_node = current_node[f]
2220

21+
dfs(graph, 0)
22+
23+
def dfs(node, depth):
24+
for key in sorted(node.keys()):
25+
print('--' * depth + key)
26+
dfs(node[key], depth + 1)
2327

2428
if __name__ == '__main__':
2529
main()

0 commit comments

Comments
 (0)