给出 n 个长度为 m 的字符串,定义一次操作(i , j , k)表示可以按任意选取1 <= i < j <= n ,1 <= k <= m ,使得编号为 i , j的两个字符串的长度为 k 的前缀互换;问任意多次操作后能得到的不同字符串的最大数量。
你可以将这 n 个字符串看为一个集合,然后将每一次操作后新产生的字符串加入到这个集合中,众所周知集合是满足互异性的,即集合内的字符串不能有相同。答案相当于经过任意多次操作后,集合所包含的最多的元素个数是多少
One day little Vasya found mom’s pocket book. The book had $ n $ names of her friends and unusually enough, each name was exactly $ m $ letters long. Let’s number the names from $ 1 $ to $ n $ in the order in which they are written.
As mom wasn’t home, Vasya decided to play with names: he chose three integers $ i $ , $ j $ , $ k $ ( $ 1<=i You wonder how many different names Vasya can write instead of name number $ 1 $ , if Vasya is allowed to perform any number of the described actions. As Vasya performs each action, he chooses numbers $ i $ , $ j $ , $ k $ independently from the previous moves and his choice is based entirely on his will. The sought number can be very large, so you should only find it modulo $ 1000000007 $ $ (10^{9}+7) $ . The first input line contains two integers $ n $ and $ m $ ( $ 1<=n,m<=100 $ ) — the number of names and the length of each name, correspondingly. Then $ n $ lines contain names, each name consists of exactly $ m $ uppercase Latin letters. Print the single number — the number of different names that could end up in position number $ 1 $ in the pocket book after the applying the procedures described above. Print the number modulo $ 1000000007 $ $ (10^{9}+7) $ . In the first sample Vasya can get the following names in the position number $ 1 $ : “AAB”, “AAA”, “BAA” and “BAB”. 我们看看样例: 在这个数据中,每个字符串的各位不相等的数量分别为:2,1,2(AB,A,BA)。 根据组合数中的乘法原理:
N
=
m
1
∗
m
2
∗
.
.
.
∗
m
n
N
=
m
1
∗
m
2
∗
.
.
.
∗
m
n
N=m1∗m2∗...∗mnN=m_1*m_2*...*m_n
N=m1∗m2∗...∗mnN=m1∗m2∗...∗mn。所以我们只需找出每个字符串中各位不相等的数量,再将其相乘即可。输入格式
输出格式
样例 #1
样例输入 #1
2 3
AAB
BAA
样例输出 #1
4
样例 #2
样例输入 #2
4 5
ABABA
BCGDG
AAAAA
YABSA
样例输出 #2
216
提示
分析
AAB
BAA
代码
#include