Substring Query
Time limit10sMemory limit512 MB
Given n strings of a and b, answer q queries: how many strings with index in [l, r] contain the pattern P as a substring.
- Level
Hard8 of 10
- Topics
- String matching, Trie, Sorting
- Solved
- No attempts yet
Problem
Bobo has strings . One day, his friend yiyi comes and asks him questions. Each question asks how many strings in contain as a substring. Help Bobo find the answers.
Input
The first line contains two integers , (). Each of the following lines contains one string (). Each of the last lines contains two integers , and one string (, ). All strings consist of the characters a and b.
Output
For each question, print a single integer, the answer to that question.