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

32927번 - Longest Common Substring 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 2048 MB23131368.421%

문제

Lisa wrote a program to solve the Longest Common Substring problem. She then used the program to find, for some two strings $s$ and $t$ consisting of characters '0' and '1', the longest string $w$ that is a substring of both $s$ and $t$. If there were multiple such longest strings, she found an arbitrary one.

Notably, the length of $w$ Lisa found was very small --- at most 3.

Lisa remembers $n$ (the length of $s$), $m$ (the length of $t$), and $w,ドル but she doesn't remember strings $s$ and $t$ themselves. Now she wonders how many pairs of strings $s$ and $t$ exist such that they have lengths $n$ and $m,ドル respectively, consist of characters '0' and '1', and have $w$ as one of their longest common substrings.

Help Lisa and find this number of pairs modulo 998ドル,244円,353円$. Note that if $n = m$ and $s \ne t,ドル pairs $(s, t)$ and $(t, s)$ are considered distinct.

입력

The first line contains three integers $n,ドル $m,ドル and $k,ドル denoting the lengths of the strings $s,ドル $t,ドル and $w$ (1ドル \le n, m \le 100$; 1ドル \le k \le \min(3, n, m)$).

The second line contains the string $w$ of length $k$ consisting of characters '0' and '1'.

출력

Print the number of pairs of strings $(s, t)$ that have $w$ as one of their longest common substrings, modulo 998ドル,244円,353円$.

제한

예제 입력 1

2 2 1
1

예제 출력 1

6

예제 입력 2

3 4 2
01

예제 출력 2

28

예제 입력 3

7 5 3
110

예제 출력 3

399

예제 입력 4

23 42 3
000

예제 출력 4

174497840

노트

Note that a string $a$ is a substring of a string $b$ if $a$ can be obtained from $b$ by deleting zero or more characters from the beginning and zero or more characters from the end.

In the first test, all pairs of strings satisfying the conditions are ("01", "10"), ("01", "11"), ("10", "01"), ("10", "11"), ("11", "01"), and ("11", "10").

출처

ICPC > Regionals > Northern Eurasia > Northwestern Russia Regional Contest > ICPC 2024-2025 Northwestern Russia Regional Contest L번

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

출처

대학교 대회

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

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