Logo
(追記) (追記ここまで)

33064번 - It's Mooin' Time 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB33914412046.693%

문제

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 $N$ (3ドル \leq N \leq 20,000円$). A moo is generally defined as the substring $c_ic_jc_j$ where some character $c_i$ followed directly by 2ドル$ occurrences of some character $c_j$ where $c_i \neq c_j$. According to Farmer John, Bessie moos a lot, so if some moo appears at least $F$ (1ドル\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 $N$ and $F,ドル 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 $N,ドル 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

In this case, no character change affects the answer. The only moo Bessie made was "moo".

예제 입력 2

17 2
momoobaaaaaqqqcqq

예제 출력 2

3
aqq
baa
cqq
In this case, the $a$ at position 8ドル$ (zero-indexed) could have been corrupted from a $b$ which would have resulted in "baa" being a moo that Bessie made twice. Alternatively, the $q$ at position 11ドル$ could have been corrupted from a $c$ which would have resulted in "cqq" being a possible moo that Bessie made. "aqq" can be made by swapping the $c$ with an $a$.

예제 입력 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

힌트

출처

Olympiad > USA Computing Olympiad > 2024-2025 Season > USACO 2024 December Contest > Bronze 3번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /