#P12116. [NWRRC2024] Longest Common Substring

    ID: 12036 Type: RemoteJudge 5000ms 1024MiB Tried: 0 Accepted: 0 Difficulty: 6 Uploaded By: Tags>动态规划 DP2024快速莫比乌斯变换 FMTICPC状压 DPNWRRC

[NWRRC2024] Longest Common Substring

题目描述

Lisa wrote a program to solve the Longest Common Substring problem. She then used the program to find, for some two strings ss and tt consisting of characters 0\tt{0} and 1\tt{1}, the longest string ww that is a substring of both ss and tt. If there were multiple such longest strings, she found an arbitrary one.

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

Lisa remembers nn (the length of ss), mm (the length of tt), and ww, but she doesn't remember strings ss and tt themselves. Now she wonders how many pairs of strings ss and tt exist such that they have lengths nn and mm, respectively, consist of characters 0\tt{0} and 1\tt{1}, and have ww as one of their longest common substrings.

Help Lisa and find this number of pairs modulo 998244353998\,244\,353. Note that if n=mn = m and sts \ne t, pairs (s,t)(s, t) and (t,s)(t, s) are considered distinct.

输入格式

The first line contains three integers nn, mm, and kk, denoting the lengths of the strings ss, tt, and ww (1n,m1001 \le n, m \le 100; 1kmin(3,n,m)1 \le k \le \min(3, n, m)).

The second line contains the string ww of length kk consisting of characters 0\tt{0} and 1\tt{1}.

输出格式

Print the number of pairs of strings (s,t)(s, t) that have ww as one of their longest common substrings, modulo 998244353998\,244\,353.

2 2 1
1
6
3 4 2
01
28
7 5 3
110
399
23 42 3
000
174497840

提示

Note that a string aa is a substring of a string bb if aa can be obtained from bb 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\tt{01}, 10\tt{10}), (01\tt{01}, 11\tt{11}), (10\tt{10}, 01\tt{01}), (10\tt{10}, 11\tt{11}), (11\tt{11}, 01\tt{01}), and (11\tt{11}, 10\tt{10}).