#P2679. [NOIP 2015 提高组] 子串
[NOIP 2015 提高组] 子串
Description
There are two strings and consisting only of lowercase English letters.
We will select pairwise non-overlapping, non-empty substrings from string , then concatenate these substrings in the order they appear in to obtain a new string. How many ways are there to make this new string equal to string ?
Note: Different selection positions are considered different ways.
Input Format
The first line contains three positive integers , representing the length of string , the length of string , and the mentioned in the problem statement, respectively. Each pair of integers is separated by a single space.
The second line contains a string of length , which is string .
The third line contains a string of length , which is string .
Output Format
Output a single integer, the number of required ways.
Since the answer may be large, output the result modulo .
6 3 1
aabaab
aab
2
6 3 2
aabaab
aab
7
6 3 3
aabaab
aab
7
Hint
Sample Explanation
All valid ways are as follows (the underlined parts indicate the selected substrings):
Sample 1: .
Sample 2: $\texttt{\underline{a}\,\underline{ab}\,aab,\underline{a}\,aba\,\underline{ab},a\,\underline{a}\,ba\,\underline{ab},aab\,\underline{a}\,\underline{ab},\underline{aa}\,\underline{b}\,aab,\underline{aa}\,baa\,\underline{b},aab\,\underline{aa}\,\underline{b}}$.
Sample 3: $\texttt{\underline{a}\,\underline{a}\,\underline{b}\,aab,\underline{a}\,\underline{a}\,baa\,\underline{b},\underline{a}\,ab\,\underline{a}\,a\,\underline{b},\underline{a}\,aba\,\underline{a}\,\underline{b},a\,\underline{a}\,b\,\underline{a}\,a\,\underline{b},a\,\underline{a}\,ba\,\underline{a}\,\underline{b},aab\,\underline{a}\,\underline{a}\,\underline{b}}$.
Constraints
For testdata 1: ;
For testdata 2 to 3: ;
For testdata 4 to 5: ;
For testdata 1 to 7: ;
For testdata 1 to 9: ;
For all 10 testdata sets: .
Translated by ChatGPT 5
京公网安备 11011102002149号