diff --git a/tgyuuAn/README.md b/tgyuuAn/README.md index 54dec912..5fd3dcb3 100644 --- a/tgyuuAn/README.md +++ b/tgyuuAn/README.md @@ -39,11 +39,12 @@ | 35차시 | 2023.01.25 | 이분 탐색 | 공유기 설치 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/120 | 36차시 | 2023.02.04 | BFS | 로봇 청소기 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/126 | 37차시 | 2023.02.04 | BFS | 교환 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/131 -| 38차시 | 2023.02.15 | DP | 피보나치 수 3 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/137 +| 38차시 | 2023.02.15 | DP | 피보나치 수 3 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/138 | 39차시 | 2023.02.18 | DP | | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/139 | 40차시 | 2023.02.21 | DP | 입대 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/142 | 41차시 | 2023.03.04 | DP | 자두나무 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/148 | 42차시 | 2023.03.07 | DFS | 스도쿠 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/152 | 43차시 | 2024.03.10 | 이분 탐색 | 징검다리 건너기 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/157 | 44차시 | 2023.03.13 | 트라이 | 개미굴 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/159 +| 45차시 | 2023.03.16 | 트라이 | 트라이 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/162 --- diff --git "a/tgyuuAn/\355\212\270\353\235\274\354\235\264/\353\224\224\354\212\244\355\201\254 \355\212\270\353\246\254.py" "b/tgyuuAn/\355\212\270\353\235\274\354\235\264/\353\224\224\354\212\244\355\201\254 \355\212\270\353\246\254.py" new file mode 100644 index 00000000..db7bf90e --- /dev/null +++ "b/tgyuuAn/\355\212\270\353\235\274\354\235\264/\353\224\224\354\212\244\355\201\254 \355\212\270\353\246\254.py" @@ -0,0 +1,48 @@ +import sys + +def input(): return sys.stdin.readline().rstrip() + +N = int(input()) + +class Node(): + def __init__(self, key): + self.key = key + self.children = {} + +class Tries(): + def __init__(self): + self.head = Node(None) + + def insert(self, path): + now = self.head + directories = path.split("\\") + + for directory in directories: + if directory not in now.children: + now.children[directory] = Node(directory) + + now = now.children[directory] + + def dfs(self, now : Node, depth): + if now.key is not None: + for _ in range(depth): + print(" ", end="") + print(now.key) + + now_children = list(now.children.keys()) + now_children.sort() + + for child in now_children: + self.dfs(now.children[child], depth+1) + + def display_all(self): + now = self.head + self.dfs(now, -1) + +tries = Tries() + +for _ in range(N): + path = input() + tries.insert(path) + +tries.display_all() \ No newline at end of file