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

建议使用的浏览器:

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

5384:Danganronpa

题目描述
Danganronpa is a video game franchise created and developed by Spike Chunsoft, the series' name is compounded from the Japanese words for "bullet" (dangan) and "refutation" (ronpa).

Now, Stilwell is playing this game. There are $n$ verbal evidences, and Stilwell has $m$ "bullets". Stilwell will use these bullets to shoot every verbal evidence.

Verbal evidences will be described as some strings $A_i$, and bullets are some strings $B_j$. The damage to verbal evidence $A_i$ from the bullet $B_j$ is $f(A_i,B_j)$.
$$f(A,B)=\sum_{i=1}^{|A|-|B|+1}[~A[i...i+|B|-1]=B~]$$In other words, $f(A,B)$ is equal to the times that string $B$ appears as a substring in string $A$.
For example: $f(ababa,ab)=2$, $f(ccccc,cc)=4$

Stilwell wants to calculate the total damage of each verbal evidence $A_i$ after shooting all $m$ bullets $B_j$, in other words is $\sum_{j=1}^m f(A_i,B_j)$.
输入解释
The first line of the input contains a single number $T$, the number of test cases.
For each test case, the first line contains two integers $n$, $m$.
Next $n$ lines, each line contains a string $A_i$, describing a verbal evidence.
Next $m$ lines, each line contains a string $B_j$, describing a bullet.

$T\leq 10$
For each test case, $n,m\leq 10^5$, $1\leq |A_i|,|B_j|\leq 10^4$, $\sum |A_i|\leq 10^5$, $\sum |B_j|\leq 10^5$
For all test case, $\sum |A_i|\leq 6*10^5$, $\sum |B_j|\leq 6*10^5$, $A_i$ and $B_j$ consist of only lowercase English letters
输出解释
For each test case, output $n$ lines, each line contains a integer describing the total damage of $A_i$ from all $m$ bullets, $\sum_{j=1}^m f(A_i,B_j)$.
输入样例
1
5 6
orz
sto
kirigiri
danganronpa
ooooo
o
kyouko
dangan
ronpa
ooooo
ooooo
输出样例
1
1
0
3
7
来自杭电HDUOJ的附加信息
Author SXYZ
Recommend wange2014

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

源链接: HDU-5384

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

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 131072/131072K(Java/Others)