Shh

시간 제한1초메모리 제한2048 MB

요약
문자열이 부분 문자열 "shh"를 정확히 k번 포함하도록 최소 개수의 문자를 바꾸고, 그 최소 횟수만큼 바꿔서 조건을 만족하는 서로 다른 비밀번호의 개수를 67로 나눈 나머지를 구한다.
난이도

어려움10점 중 9점

유형
동적 계획법, 조합론, 문자열, 수학
정답자
아직 제출이 없습니다

문제

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 kk different instances of the substring shh.

A string bb is a substring of a string aa if bb can be obtained from aa 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 kk 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 kk different instances of the substring shh.

입력

The first line contains two integers, nn and kk (1≤n≤67,0≤3k≤n1 \le n \le 67, 0 \le 3k \le n). The second line contains a string of nn lowercase letters, Theo's original password.

출력

Let cc be the minimum number of characters Theo needs to change. Let ww be the number of distinct passwords with exactly kk different instances of the substring shh that can be obtained by changing exactly cc characters. Output two integers: cc, and the remainder when ww is divided by the prime 6767.

힌트

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.

예제8

  1. 예제 1

    입력
    10 2
    eurovision
    
    예상 출력
    5 4
    
  2. 예제 2

    입력
    8 1
    sixseven
    
    예상 출력
    2 2
    
  3. 예제 3

    입력
    3 0
    shh
    
    예상 출력
    1 8
    
  4. 예제 4

    입력
    2 0
    no
    
    예상 출력
    0 1
    
  5. 예제 5

    입력
    10 0
    wastedlove
    
    예상 출력
    0 1
    
  6. 예제 6

    입력
    18 6
    countingsatellites
    
    예상 출력
    18 1
    
  7. 예제 7

    입력
    22 5
    notanotherconstructive
    
    예상 출력
    13 19
    
  8. 예제 8

    입력
    14 3
    honkaistarrail
    
    예상 출력
    8 13