Skip to content

Commit 4bb8b86

Browse files
Merge pull request #719 from baekhangyeol/main
[백한결] 113차 라이브 코테 제출
2 parents ab57dd8 + f0c844a commit 4bb8b86

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import sys
2+
3+
def main():
4+
input = sys.stdin.readline
5+
t = int(input())
6+
7+
for _ in range(t):
8+
phoneNumber = []
9+
n = int(input())
10+
for i in range(n):
11+
phoneNumberStr = input().strip()
12+
phoneNumber.append(phoneNumberStr)
13+
14+
phoneNumber.sort()
15+
16+
isOk = True
17+
for i in range(len(phoneNumber)-1):
18+
if phoneNumber[i+1].startswith(phoneNumber[i]):
19+
print("NO")
20+
isOk = False
21+
break
22+
if isOk:
23+
print("YES")
24+
25+
if __name__ == '__main__':
26+
main()
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import sys
2+
from collections import defaultdict
3+
4+
def main():
5+
input = sys.stdin.readline
6+
N = int(input())
7+
8+
graph = defaultdict(dict)
9+
10+
for _ in range(N):
11+
food = input().strip().split()
12+
K = int(food[0])
13+
foods = food[1:]
14+
15+
current_node = graph
16+
for f in foods:
17+
if f not in current_node:
18+
current_node[f] = defaultdict(dict)
19+
current_node = current_node[f]
20+
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)
27+
28+
if __name__ == '__main__':
29+
main()

0 commit comments

Comments
 (0)