描述
传送门:hdu-2222
In the modern time, Search engine came into the life of everybody like Google, Baidu, etc.
Wiskey also wants to bring this feature to his image retrieval system.
Every image have a long description, when users type some keywords to find the image, the system will match the keywords with description of image and show the image which the most keywords be matched.
To simplify the problem, giving you a description of image, and some keywords, you should tell me how many keywords will be match.
Input
First line will contain one integer means how many cases will follow by.
Each case will contain two integers N means the number of keywords and N keywords follow. (N <= 10000)
Each keyword will only contains characters ‘a’-‘z’, and the length will be not longer than 50.
The last line is the description, and the length will be not longer than 1000000.
Output
Print how many keywords are contained in the description.
Examples
intput
1
2
3
4
5
6
7
81
5
she
he
say
shr
her
yasherhsoutput
1
3
题目大意
- 给你n个模式串,再给你一个匹配串,让你求有多少种模式串在匹配传中出现过。
思路
- AC自动机裸题,先根据给的模式串建一棵trie树,再在上面bfs建失配指针。
代码
1 |
|