전.py
[python] 백준 1141 접두사
jeonnew
2022. 1. 11. 16:28
728x90
https://www.acmicpc.net/problem/1141
1141번: 접두사
접두사X 집합이란 집합의 어떤 한 단어가, 다른 단어의 접두어가 되지 않는 집합이다. 예를 들어, {hello}, {hello, goodbye, giant, hi}, 비어있는 집합은 모두 접두사X 집합이다. 하지만, {hello, hell}, {giant,
www.acmicpc.net
n = int(input())
l = []
for i in range(n):
l.append(input())
l = list(set(l))
result = 0
for i in range(len(l)):
for j in range(len(l)):
if len(l[i]) <= len(l[j]) and i != j:
if l[i] == l[j][:len(l[i])]:
result += 1
break
print(len(l)-result)
부분집합이라니
반응형