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

建议使用的浏览器:

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

7081:Pty loves book

题目描述
Pty has a string s and a dictionary.

There are m words in the dictionary. Each word $t_i$ has its value $w_i$.

Define function $f(s,l,r)=$$\sum_{i=1}^m$$occur(s,l,r,t_i)*w_i$ , where $occur(s,l,r,t_i)$ is the number of occurrences of string $t_i$ in s[l...r]

The interest value of string s is $\sum_{l=1}^{\mid s \mid}$$\sum_{r=l}^{\mid s \mid}$$f(s,l,r)^5$

Pty wants to know the interest value of string s.

Since the answer might be very large, print the answer modulo $10^9$ + 7.
输入解释
The first line of input contains a integer T(1 ≤ T ≤ 11), the number of test cases.

For each case, the first line of input contains a string s (1 ≤$\mid s \mid$≤ 5×$10^5$).

The second line contains a integer m(0 ≤ m ≤ 5×$10^5$).

There are m lines next. The $i^{th}$ line contains a string ti and a integer $w_i$(0 ≤ $\sum_{i=1}^m \mid t_i \mid$ ≤ 5×$10^5$ , 1 ≤$w_i$≤ $10^9 + 7$).

It’s guaranteed that s,$t_i$ are non-empty strings.
输出解释
For each test case, print the interest value of string s, modulo $10^9$ + 7 in one line.
输入样例
1
whkfqbw
3
h 3
hkfq 2
qb 2
输出样例
75128

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

源链接: HDU-7081

最后修改于 2021-10-23T19:11:21+00:00 由爬虫自动更新

共提交 0

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