#P6216. 回文匹配
回文匹配
Problem Description
For a pair of strings , for every substring of with odd length, if is a palindrome, then the “score” of increases by the number of occurrences of inside .
Now you are given a pair . Please compute the “score” of .
Output the answer modulo .
Input Format
The first line contains two integers , representing the lengths of and .
The second line contains two strings .
Output Format
Output one integer on a single line, representing the score of .
10 2
ccbccbbcbb bc
4
20 2
cbcaacabcbacbbabacca ba
4
Hint
Sample Explanation
For sample 1:
appears once in the substring , and once in the substring .
appears once in the substring , and once in the substring .
Constraints
This problem uses bundled testdata.
-
For of the testdata: , and all characters in the strings are lowercase letters.
-
Detailed constraints:
Subtask ID Points
Translated by ChatGPT 5