#P6695. 谷歌翻(sheng)译(cao)机(加强版)
谷歌翻(sheng)译(cao)机(加强版)
Description
Note: For convenience, in the following, all strings are 1-indexed, i.e. positions start from .
Xiao L treats the original text before each meme-making and the result after meme-making as two strings and , both consisting only of lowercase letters.
We define a “split sequence” and “split substring” as follows:
-
For a string of length , a “split sequence” is defined as: there exists a sequence of length such that . For a split sequence, its “split substrings” are the substrings formed by the characters from position to () (they can be empty strings). Clearly, for a split sequence of length , there are split substrings in total.
-
For the same string, two split sequences ( and ) are different if and only if the lengths of the two sequences are different (), or there exists an such that .
Different people may have different interpretation methods for the same original text and result. We define an interpretation method as follows:
- For strings and , we find one split sequence for each of them ( and ). These two split sequences must satisfy:
- The two split sequences have the same length ().
- For any , , i.e. the character at position in is the same as the character at position in .
-
Define the “meme level” (shengcao degree) of this interpretation method as the sum of the -th powers of the lengths of all split substrings in the two strings, i.e. $\sum\limits_{i=0}^{k_1}(p_{i+1}-p_i-1)^t+\sum\limits_{i=0}^{k_2}(q_{i+1}-q_i-1)^t$.
-
Two interpretation methods are different if and only if their are different, or their are different.
Xiao L wants to know the sum of the meme levels over all interpretation methods. Since he (also) does not like the number , he does not want you to tell him the result as that number, so you need to take the result modulo .
Input Format
The first line contains three positive integers .
The next line contains a string of length , representing string .
The next line contains a string of length , representing string .
Output Format
One line containing one integer, the answer modulo .
3 4 2
abc
bacb
74
7 8 5
ccbbacb
bbbdadba
337322
3 4 1000000
abc
bacb
424285944
Hint
For Sample 1, there are the following interpretation methods:
- , meme level is .
- , meme level is .
- , meme level is .
- , meme level is .
- , meme level is .
- , meme level is .
- , meme level is .
- , meme level is .
The total meme level is .
Constraints
“This problem uses bundled subtasks.”
- Subtask 1 ( ): .
- Subtask 2 ( ): .
- Subtask 3 ( ): .
- Subtask 4 ( ): no special restrictions.
For of the testdata, , and and contain only lowercase letters.
Translated by ChatGPT 5
京公网安备 11011102002149号