#698
Bronze I
It's Mooin' Time
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Farmer John is trying to describe his favorite USACO contest to Elsie, but she is having trouble understanding why he likes it so much. He says "My favorite part of the contest was when Bessie said 'It's Mooin' Time' and mooed all over the contest."

Elsie still doesn't understand so Farmer John downloads the contest as a text file and tries to explain what he means. The contest is defined as a string of lowercase letters of length NN (3N200003 \leq N \leq 20\,000). A moo is generally defined as the substring cicjcjc_ic_jc_j where some character cic_i followed directly by 22 occurrences of some character cjc_j where cicjc_i \neq c_j. According to Farmer John, Bessie moos a lot, so if some moo appears at least FF (1FN1\le F\le N) times in the contest, that might be from Bessie.

However, Farmer John's download might have been corrupted, and the text file might have up to one character that differs from the original file. Print all possible moos that Bessie could have made taking the potential error into account, sorted in alphabetical order.

입력

The first line contains NN and FF, representing the length of the string and the frequency threshold for a moo by Bessie.

The second line contains a string of lowercase letters of length NN, representing the contest.

출력

Print out the number of possible moos that Bessie makes, followed by a lexicographically sorted list of the moos. Each moo should appear on a separate line.

예제 입력 1

10 2
zzmoozzmoo

예제 출력 1

1
moo

예제 입력 2

17 2
momoobaaaaaqqqcqq

예제 출력 2

3
aqq
baa
cqq

예제 입력 3

3 1
ooo

예제 출력 3

25
aoo
boo
coo
doo
eoo
foo
goo
hoo
ioo
joo
koo
loo
moo
noo
poo
qoo
roo
soo
too
uoo
voo
woo
xoo
yoo
zoo

점수

Inputs 4-8: N100N \le 100 Inputs 9-13: No additional constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Bronze I1명 투표· 약 1개월 전
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.