CF1202E.You Are Given Some Strings...
提高+/省选-
通过率:0%
时间限制:3.00s
内存限制:256MB
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.
给你一个字符串 t 和 n 个字符串 s1,s2,…,sn。所有字符串均由小写拉丁字母组成。
定义 f(t,s) 为字符串 s 在字符串 t 中的出现次数。例如,f(′aaabacaa′,′aa′)=3,而 f(′ababa′,′aba′)=2。
请计算 i=1∑nj=1∑nf(t,si+sj) 的值,其中 s+t 表示字符串 s 与 t 的拼接。注意:若存在两对下标 (i1,j1) 和 (i2,j2) 满足 si1+sj1=si2+sj2,则答案中需同时包含 f(t,si1+sj1) 和 f(t,si2+sj2)。
输入格式
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.
第一行包含字符串 t(1≤∣t∣≤2⋅105)。
第二行包含整数 n(1≤n≤2⋅105)。
接下来的 n 行,每行包含一个字符串 si(1≤∣si∣≤2⋅105)。
保证 i=1∑n∣si∣≤2⋅105。所有字符串均由小写英文字母组成。
输出格式
Print one integer — the value of i=1∑nj=1∑nf(t,si+sj).
输出一个整数——即 i=1∑nj=1∑nf(t,si+sj) 的值。
输入输出样例
输入#1
aaabacaa 2 a aa
输出#1
5
输入#2
aaabacaa 4 a a a b
输出#2
33
输入解题思路,AI测评打分。不知道怎么写?