#P10479. 匹配统计
匹配统计
Problem Description
Axuan wrote two strings on paper, denoted as and . Using what he learned in data structures and algorithms class, he can easily compute, for any starting position in string , the matching length between the suffix substring starting from that position and string .
However, Axuan is a hardworking and curious student, and he asks you questions. In each question, he gives you an integer . You need to tell him how many starting positions satisfy that the matching length between the suffix substring of starting at that position and is exactly .
For example: , . Then has suffix substrings: , , , , , . Their matching lengths with are . Therefore, in , there are positions whose matching length with is exactly , position whose matching length is exactly , and position whose matching length is exactly .
Input Format
The first line contains three integers , representing the length of string , the length of string , and the number of queries.
The second line is string , and the third line is string .
In the next lines, each line contains one integer , representing one query.
Output Format
Output lines. Each line is the answer to the corresponding query, in order.
6 2 5
aabcde
ab
0
1
2
3
4
4
1
1
0
0
Hint
Constraints: 。
Translated by ChatGPT 5