RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0629

It's Mooin' Time

Gold IV 골드 IV
난이도
2s
시간 제한
256MB
메모리 제한
1
맞았습니다!!
1
제출 수
100.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 \(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.

Problem credits: Suhas Nagar

제약

SCORING

  • Inputs 4-8: \(N \le 100\)
  • Inputs 9-13: No additional constraints.

Problem credits: Suhas Nagar

입력 형식

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
moo
설명

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

예제 2
입력
17 2
momoobaaaaaqqqcqq
출력
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
출력
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
문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2024-2025 > December > Bronze

태그

평가 및 의견

It's Mooin' Time

개요
출제자 난이도 Gold IV 골드 IV 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

It's Mooin' Time

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8