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

20027번 - LCS 8 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 (추가 시간 없음) 1024 MB84382145.652%

문제

You are given a string $S$ of length $N,ドル consisting of uppercase letters, and a small nonnegative integer $K$.

Please compute the number of strings $T$ of length $N,ドル consisting of only uppercase letters, such that the longest common subsequence of $S$ and $T$ has length at least $N - K$. As the number could be large, print the number of such strings modulo 10ドル^9 + 7$.

A string $S = s_1s_2\ldots s_n$ is a subsequence of a string $T = t_1t_2\ldots t_m$ if there exists an increasing sequence of indices 1ドル \le i_1 < i_2 < \ldots < i_n \le m$ such that $s_x = t_{i_x}$ for all 1ドル \le x \le n$.

입력

The first line of the input contains the length-$N$ string $S$ (1ドル \le |S| \le 50,000円$). All characters of $S$ are uppercase letters.

The next line of the input contains the single integer $K$ (0ドル \le K \le 3)$.

출력

Print the number of such strings modulo 10ドル^9 + 7$.

제한

예제 입력 1

ACAYKP
0

예제 출력 1

1

예제 입력 2

CAPCAK
1

예제 출력 2

896

예제 입력 3

WEDONTNEEDNOEDUCATION
2

예제 출력 3

24651976

예제 입력 4

WEDONTNEEDNOTHOUGHTCONTROL
3

예제 출력 4

224129308

힌트

출처

University > KAIST > KAIST ICPC Mock Competition > 2020 KAIST 10th ICPC Mock Competition E번

Contest > Open Cup > 2020/2021 Season > Stage 3: Grand Prix of Korea G번

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

출처

대학교 대회

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

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