CF1202E.You Are Given Some Strings...
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a string t and n strings s1,s2,…,sn . All strings consist of lowercase Latin letters.
Let f(t,s) be the number of occurences of string s in string t . For example, f(′aaabacaa′,′aa′)=3 , and f(′ababa′,′aba′)=2 .
Calculate the value of i=1∑nj=1∑nf(t,si+sj) , where s+t is the concatenation of strings s and t . Note that if there are two pairs i1 , j1 and i2 , j2 such that si1+sj1=si2+sj2 , you should include both f(t,si1+sj1) and f(t,si2+sj2) in answer.
输入格式
The first line contains string t ( 1≤∣t∣≤2⋅105 ).
The second line contains integer n ( 1≤n≤2⋅105 ).
Each of next n lines contains string si ( 1≤∣si∣≤2⋅105 ).
It is guaranteed that i=1∑n∣si∣≤2⋅105 . All strings consist of lowercase English letters.
输出格式
Print one integer — the value of i=1∑nj=1∑nf(t,si+sj) .
输入输出样例
输入#1
aaabacaa 2 a aa
输出#1
5
输入#2
aaabacaa 4 a a a b
输出#2
33