#P3735. [HAOI2017] 字符串
[HAOI2017] 字符串
Description
Given a string and strings , for each string count the number of its occurrences in . Note that the definition of equality between two strings is slightly modified here.
Given a constant , for two strings , we define if the following hold:
- .
- For all and , it holds that .
If , then we regard .
Input Format
The first line contains an integer .
The second line contains a string .
The third line contains an integer , followed by lines, each containing a string denoting .
All characters have ASCII codes in the range to .
Output Format
Output lines, where the -th line is the number of occurrences of in .
1
xyz
3
xz
y
xzy
2
3
0
Hint
For , , because there is only one differing position.
For , , similarly.
For , , the maximum difference does not satisfy .
Constraints
- For of the testdata, it holds that: .
- For another of the testdata, it holds that: .
- For another of the testdata, it holds that: .
- For of the testdata, it holds that: .
Translated by ChatGPT 5
京公网安备 11011102002149号