#P12116. [NWRRC2024] Longest Common Substring
[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 and consisting of characters and , the longest string that is a substring of both and . If there were multiple such longest strings, she found an arbitrary one.
Notably, the length of Lisa found was very small --- at most 3.
Lisa remembers (the length of ), (the length of ), and , but she doesn't remember strings and themselves. Now she wonders how many pairs of strings and exist such that they have lengths and , respectively, consist of characters and , and have as one of their longest common substrings.
Help Lisa and find this number of pairs modulo . Note that if and , pairs and are considered distinct.
输入格式
The first line contains three integers , , and , denoting the lengths of the strings , , and (; ).
The second line contains the string of length consisting of characters and .
输出格式
Print the number of pairs of strings that have as one of their longest common substrings, modulo .
2 2 1
1
6
3 4 2
01
28
7 5 3
110
399
23 42 3
000
174497840
提示
Note that a string is a substring of a string if can be obtained from 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 (, ), (, ), (, ), (, ), (, ), and (, ).