#P204E. Little Elephant and Strings
Little Elephant and Strings
Little Elephant and Strings
题面翻译
给定一个字符串序列 ,对于每个 ,求出多少对 ,满足 是 中至少 个串的子串。
,。
题目描述
The Little Elephant loves strings very much.
He has an array from strings, consisting of lowercase English letters. Let's number the elements of the array from 1 to , then let's denote the element number as . For each string the Little Elephant wants to find the number of pairs of integers and such that substring is a substring to at least strings from array (including the -th string).
Help the Little Elephant solve this problem.
If you are not familiar with the basic notation in string problems, you can find the corresponding definitions in the notes.
输入格式
The first line contains two space-separated integers — and . Next lines contain array . The -th line contains a non-empty string , consisting of lowercase English letter. The total length of all strings does not exceed .
输出格式
On a single line print space-separated integers — the -th number is the answer for string .
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
样例 #1
样例输入 #1
3 1
abc
a
ab
样例输出 #1
6 1 3
样例 #2
样例输入 #2
7 4
rubik
furik
abab
baba
aaabbbababa
abababababa
zero
样例输出 #2
1 0 9 9 21 30 0
提示
Let's assume that you are given string , then let's denote the string's length as and the string's -th character as .
A substring of string is string .
String is a substring of string , if there exists such pair of integers and , that .