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

19377번 - K-th String 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB1611763.636%

문제

Alice has $n \le 26$ cards, and each card is labeled with one of the first $n$ lowercase English letters. For example, if $n = 3,ドル Alice has three cards that are labeled "a'', "b'', and "c''. Alice constructed a string $t$ by permuting these cards. Furthermore, she considered all non-empty substrings of $t$ and sorted them lexicographically. It turned out that the $k$-th string in this sorted list of substrings was $s$. How many $t$'s are possible?

For example, if $n = 3$ and $t = cab,ドル the sorted list is a, ab, b, c, ca, cab, and the third string in the sorted list is b. When $k = 3$ and $s = b,ドル there are two possibilites for $t$: cab and bac.

Compute the number of possible $t$'s that are consistent with the given information, modulo 10ドル^9 + 7$. Note that Alice may have made mistakes, in which case the number of possible $t$'s is zero.

입력

On the first line, you are given two space-separated integers $n$ and $k$. On the next line, you are given the string $s$ (1ドル \le n \le 26,ドル 1ドル \le k \le n (n + 1) / 2$). The characters in $s$ are pairwise distinct; $s$ consists of the first $n$ lowercase English letters.

출력

Print the answer on a single line.

제한

예제 입력 1

2 2
b

예제 출력 1

1

예제 입력 2

3 3
b

예제 출력 2

2

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2017 > Day 3: Japanese Contest, Head of Republic of Karelia Cup, Round I H번

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

출처

대학교 대회

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

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