Skip to content

Commit

Permalink
Merge pull request #162 from AlgoLeadMe/45-tgyuuAn
Browse files Browse the repository at this point in the history
45-tgyuuAn
  • Loading branch information
tgyuuAn authored Mar 24, 2024
2 parents 88a639e + 2f89d84 commit 9f48183
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tgyuuAn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@
| 35์ฐจ์‹œ | 2023.01.25 | ์ด๋ถ„ ํƒ์ƒ‰ | <a href="https://www.acmicpc.net/problem/2110">๊ณต์œ ๊ธฐ ์„ค์น˜</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/120
| 36์ฐจ์‹œ | 2023.02.04 | BFS | <a href="https://www.acmicpc.net/problem/4991">๋กœ๋ด‡ ์ฒญ์†Œ๊ธฐ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/126
| 37์ฐจ์‹œ | 2023.02.04 | BFS | <a href="https://www.acmicpc.net/problem/1039">๊ตํ™˜</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/131
| 38์ฐจ์‹œ | 2023.02.15 | DP | <a href="https://www.acmicpc.net/problem/2749">ํ”ผ๋ณด๋‚˜์น˜ ์ˆ˜ 3</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/137
| 38์ฐจ์‹œ | 2023.02.15 | DP | <a href="https://www.acmicpc.net/problem/2749">ํ”ผ๋ณด๋‚˜์น˜ ์ˆ˜ 3</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/138
| 39์ฐจ์‹œ | 2023.02.18 | DP | <a href="https://www.acmicpc.net/problem/7579">์•ฑ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/139
| 40์ฐจ์‹œ | 2023.02.21 | DP | <a href="https://www.acmicpc.net/problem/31413">์ž…๋Œ€</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/142
| 41์ฐจ์‹œ | 2023.03.04 | DP | <a href="https://www.acmicpc.net/problem/2240">์ž๋‘๋‚˜๋ฌด</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/148
| 42์ฐจ์‹œ | 2023.03.07 | DFS | <a href="https://www.acmicpc.net/problem/2239">์Šค๋„์ฟ </a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/152
| 43์ฐจ์‹œ | 2024.03.10 | ์ด๋ถ„ ํƒ์ƒ‰ | <a href="https://school.programmers.co.kr/learn/courses/30/lessons/64062">์ง•๊ฒ€๋‹ค๋ฆฌ ๊ฑด๋„ˆ๊ธฐ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/157
| 44์ฐจ์‹œ | 2023.03.13 | ํŠธ๋ผ์ด | <a href="https://www.acmicpc.net/problem/14725">๊ฐœ๋ฏธ๊ตด</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/159
| 45์ฐจ์‹œ | 2023.03.16 | ํŠธ๋ผ์ด | <a href="https://www.acmicpc.net/problem/31413">ํŠธ๋ผ์ด</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/162
---
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 9f48183

Please sign in to comment.