BOJ - 5052 - 전화번호 목록

Updated:

import sys

def Check(data):
    data.sort()
    for i in range(len(data) - 1):
        if data[i] in data[i + 1]: 
            return False
    return True

def solution():    
    T = int(input())    
    
    ret=[]

    for _ in range(T):
        data=[]
        
        N = int(input())
        for _ in range(N):
            data.append(sys.stdin.readline().strip())
        ret.append(Check(data))

    for i in ret:
        if i:
            print('YES')
        else:
            print('NO')

solution()

https://www.acmicpc.net/problem/5052

Categories:

Updated:

Leave a comment