当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6096:String

题目描述
Bob has a dictionary with N words in it.
Now there is a list of words in which the middle part of the word has continuous letters disappeared. The middle part does not include the first and last character.
We only know the prefix and suffix of each word, and the number of characters missing is uncertain, it could be 0. But the prefix and suffix of each word can not overlap.
For each word in the list, Bob wants to determine which word is in the dictionary by prefix and suffix.
There are probably many answers. You just have to figure out how many words may be the answer.
输入解释
The first line of the input gives the number of test cases T; T test cases follow.
Each test case contains two integer N and Q, The number of words in the dictionary, and the number of words in the list.
Next N line, each line has a string Wi, represents the ith word in the dictionary ($0 < |Wi| \leq 100000$)
Next Q line, each line has two string Pi , Si, represents the prefix and suffix of the ith word in the list ($0 < |Pi|,|Si| \leq 100000, 0 < |Pi|+|Si| \leq 100000$)
All of the above characters are lowercase letters.
The dictionary does not contain the same words.

Limits
$T \leq 5$
$0 < N,Q \leq100000$
$\sum{Si +Pi} \leq 500000$
$\sum{Wi} \leq 500000$
输出解释
For each test case, output Q lines, an integer per line, represents the answer to each word in the list.
输入样例
1
4 4
aba
cde
acdefa
cdef
a a
cd ef
ac a
ce f
输出样例
2
1
1
0
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6096

最后修改于 2020-10-25T23:28:20+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
6000/3000MS(Java/Others) 524288/524288K(Java/Others)