Shh
시간 제한1초메모리 제한2048 MB
문자열이 부분 문자열 "shh"를 정확히 k번 포함하도록 최소 개수의 문자를 바꾸고, 그 최소 횟수만큼 바꿔서 조건을 만족하는 서로 다른 비밀번호의 개수를 67로 나눈 나머지를 구한다.
문제
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 different instances of the substring shh.
A string is a substring of a string if can be obtained from 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 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 different instances of the substring shh.
입력
The first line contains two integers, and (). The second line contains a string of lowercase letters, Theo's original password.
출력
Let be the minimum number of characters Theo needs to change. Let be the number of distinct passwords with exactly different instances of the substring shh that can be obtained by changing exactly characters. Output two integers: , and the remainder when is divided by the prime .
힌트
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.