## 문제
n개의 단어가 주어지면 짧은것부터, 그다음 사전순으로 정렬해야 한다.
중복된것도 제거해야하는데 set로 바꾼다음 다시 list로 바꾸면 간단하게 된다.
## code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
input = sys.stdin.readlines() | |
n1 = list(map(lambda x:x.rstrip(),input[1:])) | |
n2 = list(map(lambda x:x.replace('\x1a',''),n1)) | |
n3 = list(set(n2)) | |
l = [] | |
for tmp in n3: | |
a = len(tmp) | |
l += [[a,tmp]] | |
l.sort() | |
for tmp in l: | |
print(tmp[1]) |
0 댓글