We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d1301ac commit f0c844aCopy full SHA for f0c844a
1 file changed
live11/test113/문제2/백한결.py
@@ -1,25 +1,29 @@
1
import sys
2
from collections import defaultdict
3
4
-
5
def main():
6
input = sys.stdin.readline
7
N = int(input())
8
9
- graph = defaultdict(list)
+ graph = defaultdict(dict)
10
11
for _ in range(N):
12
- food = list(map(str, input().strip().split()))
+ food = input().strip().split()
13
K = int(food[0])
14
foods = food[1:]
15
16
current_node = graph
17
18
for f in foods:
19
if f not in current_node:
20
- current_node[f] = defaultdict(list)
+ current_node[f] = defaultdict(dict)
21
current_node = current_node[f]
22
+ dfs(graph, 0)
+
23
+def dfs(node, depth):
24
+ for key in sorted(node.keys()):
25
+ print('--' * depth + key)
26
+ dfs(node[key], depth + 1)
27
28
if __name__ == '__main__':
29
main()
0 commit comments