Nộp bài | Các bài nộp | Làm tốt nhất | Về danh sách bài |
STRMATCH - Match me if you can |
After watching the movie "Catch me if you can" professor Mahammad became very confident about creating a new problem for his programmers. As some procedures in his research heavily depend on string matching, now, he wants to check his beginner programmers' skills in this topic as well. His task is very simple. Professor gives you a random string and several queries. For each of the query string, you have to count the number of its occurrences in the string provided by professor.
Input
First line of the input section contains two positive integers N and Q, which define the length of professor's string and the number of queries, respectively.
Second line contains professor's string having length N (N ≤ 3000).
The following Q lines contain a query string having nonzero length.
Output
For each of the queries, output the number of the desired count of the occurrences.
Note: The sum of the length of query strings does not exceed 500000. And please, do consider the time limit, because the problem can be solved in both slow and fast languages.
Example
Input: 7 5
acababa
a
bb
caba
aba
karp Output: 4
0
1
2
0
Được gửi lên bởi: | mahmud2690 |
Ngày: | 2017-09-29 |
Thời gian chạy: | 1s |
Giới hạn mã nguồn: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Ngôn ngữ cho phép: | C-CLANG C CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG C99 JAVA PAS-FPC PYTHON PYTHON3 |
Nguồn bài: | Me, MYSELF & I |