#P7942. 「Wdcfr-1」CONsecutive and CONcat (easy version)
「Wdcfr-1」CONsecutive and CONcat (easy version)
题目描述
In easy version, It is guaranteed that any string in array contains at least two different letters.
Lily White is playing with strings. Being a yousei, she is not capable of complex speech. Thus, she likes strings that only contain one kind of letter, she calls such strings of length a "-CON string". For example, qqqq
is a "-CON string", while aaab
is not any type of "CON string".
Lily White composed an array . It contains strings of length that she will use to herald spring. For each permutation of , let us denote current permutation as . Lily White concatenates all the string in array in the order of into a string of length .
As she likes -CON strings, she wants to know the sum of the number of "-CON string" in all non-empty substrings of composed by all permutations. Since the answer may be enormous, just print the answer taken modulo (a large prime).
输入格式
The first line contains three integers .
Then lines follow, each line contains a string of length . The string in the-th line represents .
输出格式
Print a single integer - the answer taken modulo .
题目大意
在 easy version 中,保证所有 中的字符串至少包含两种不同的字母。
给定若干长度为 的字符串 ,给定常数 ,试求出对于所有的长度为 的排列 ,将 依次拼接形成的长字符串 中,有多少个位置 满足 为同一种字符。请输出位置数的和 的值。
3 3 4
aab
baa
baa
4
3 3 2
xyz
qaq
aba
0
提示
Explanation
Sample #1
- For permutation , the formed is
aabbaabaa
, none on the non-empty substring in this string are "-CON string". - For permutation , the formed is
aabbaabaa
, none on the non-empty substring in this string are "-CON string". - For permutation , the formed is
baaaabbaa
, this string has one substringaaaa
which is a "-CON string". - For permutation , the formed is
baabaaaab
, this string has one substringaaaa
which is a "-CON string". - For permutation , the formed is
baaaabbaa
, this string has one substringaaaa
which is a "-CON string". - For permutation , the formed is
baabaaaab
, this string has one substringaaaa
which is a "-CON string".
In summary, the answer is .
Sample #2
In all of the full permutation of length , there will be six different : xyzqaqaba
, xyzabaqaq
, qaqxyzaba
, qaqabaxyz
, abaqaqxyz
, and abaxyzqaq
. None of these has a non-empty substrings which is a "-CON string". So the answer is .
Constraints
. contains only lowercase English letters.
In easy version, we ensure that any string in array contains at least two different letters.