| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 2048 MB | 10 | 7 | 7 | 70.000% |
Theo is a little overconfident. His Spotify password has just been leaked and he needs to change it. However, he likes to say his password out loud as he types it, so he changes it so that it has $k$ different instances of the substring shh.
A string $b$ is a substring of a string $a$ if $b$ can be obtained from $a$ by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end. In particular, a string is a substring of itself. Two substrings are considered to be different instances if a different number of characters are deleted from either the beginning or the end, or both, even if the final strings are the same.
Given the original password, compute the minimum number of characters that Theo needs to change so that it has exactly $k$ different instances of the substring shh. Furthermore, compute the number of distinct passwords Theo could construct by changing exactly this many characters that also have exactly $k$ different instances of the substring shh.
The first line contains two integers, $n$ and $k$ (1ドル \le n \le 67, 0 \le 3k \le n$). The second line contains a string of $n$ lowercase letters, Theo's original password.
Let $c$ be the minimum number of characters Theo needs to change. Let $w$ be the number of distinct passwords with exactly $k$ different instances of the substring shh that can be obtained by changing exactly $c$ characters. Output two integers: $c,ドル and the remainder when $w$ is divided by the prime 67ドル$.
10 2 eurovision
5 4
8 1 sixseven
2 2
3 0 shh
1 8
2 0 no
0 1
10 0 wastedlove
0 1
18 6 countingsatellites
18 1
22 5 notanotherconstructive
13 19
14 3 honkaistarrail
8 13
For sample 1, we can show that at least 5 characters must be changed. The four passwords that can be obtained which satisfy the given constraints are shhovishhn, eshhvishhn, eushhishhn, and eurshhshhn.
ICPC > Regionals > North America > Pacific Northwest Regional > 2025 ICPC Pacific Northwest Regional > Division 1 K번
ICPC > Regionals > North America > Pacific Northwest Regional > 2025 ICPC Pacific Northwest Regional > Division 2 J번