#P2353. 背单词
背单词
Description
The teacher gives Xiao Ming an English article of length , and then asks him to memorize words. To make sure Xiao Ming does not fall asleep while memorizing, the teacher will ask questions. Each time, the teacher randomly chooses an interval , and Xiao Ming must answer how many times the words he has memorized occur in total within this segment of text.
Input Format
The first line contains two integers as described above. The second line is the English article. The next lines each contain one word to memorize. Then the next lines each contain one query with two integers (inclusive), i.e., the given interval in the text.
Output Format
Output lines. For each query, output one line with the answer.
3 3
abcabcbc
abc
bc
a
1 3
6 7
1 8
3
0
7
Hint
Constraints
- For 30% of the testdata, , .
- For 60% of the testdata, , .
- For 100% of the testdata, , , , the length of each word is between and , and .
Hint
The testdata is large, so please use efficient input/output methods.
Translated by ChatGPT 5
京公网安备 11011102002149号