Wireless Password
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4022 Accepted Submission(s): 1196
Problem Description Liyuan lives in a old apartment. One day, he suddenly found that there was a wireless network in the building. Liyuan did not know the password of the network, but he got some important information from his neighbor. He knew the password consists only of lowercase letters 'a'-'z', and he knew the length of the password. Furthermore, he got a magic word set, and his neighbor told him that the password included at least k words of the magic word set (the k words in the password possibly overlapping).
For instance, say that you know that the password is 3 characters long, and the magic word set includes 'she' and 'he'. Then the possible password is only 'she'.
Liyuan wants to know whether the information is enough to reduce the number of possible passwords. To answer this, please help him write a program that determines the number of possible passwords.
Input There will be several data sets. Each data set will begin with a line with three integers n m k. n is the length of the password (1<=n<=25), m is the number of the words in the magic word set(0<=m<=10), and the number k denotes that the password included at least k words of the magic set. This is followed by m lines, each containing a word of the magic set, each word consists of between 1 and 10 lowercase letters 'a'-'z'. End of input will be marked by a line with n=0 m=0 k=0, which should not be processed.
Output For each test case, please output the number of possible passwords MOD 20090717.
Sample Input
10 2 2
hello
world
4 1 1
icpc
10 0 0
0 0 0
Sample Output
2
1
14195065
Source 2009 Multi-University Training Contest 1 - Host by TJU
Recommend gaojie | We have carefully selected several similar problems for you: 2819 2824 2817 2823 2822 题意: 某人要去破译wifi密码。现在他已经知道密码全部由小写字母组成。且密码的长度n(1<=n<=25)。和m(0<=m<=10)个密码中可能出现的串(magic)。每个串长度不超过10.现在他已经知道密码中这m个串至少出现了k个。可以覆盖出现。现在问你密码可能有多少种。 思路: 由于是专门搜的ac自动机动规的题目。所以就直接往ac自动机动规上想了。这题的难点是确定出现magic中出现了多少个。考虑到m比较小。所以就直接壮压了。最后才取满足条件的状态就行了。 详细见代码:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include