백준 1544번: 사이클 단어 #Python

ColorlessDia·2025년 1월 15일

algorithm/baekjoon

목록 보기
423/809
import sys

N = int(sys.stdin.readline())

word_count = dict()

count = 0

for _ in range(N):
    word = sys.stdin.readline().rstrip()

    if word in word_count:
        continue
    
    count += 1

    for i in range(len(word)):
        derived_word = word[i:] + word[:i]

        word_count[derived_word] = 1

print(count)

0개의 댓글