2013年黑龙江省赛C题.Compilation【字符串匹配】
2013-05-19 22:45
183 查看
C.Compilation
Time Limited: 10S Memory Limited: 64M
Description:A program is made up of sentences.A sentence is made up of wprds.Our task is to find the number of the given N sentences in a program.
We stipulate that the word is like the form(X1X2...Xi...Xn),Xi is one of the 26 uppercase-letters.For example,(DCF) is a word.
We are sure that the program and sentences is only made up of words.
Input:
There are multiple test cases.Input data will be over by the end of the input file.
The first line of each test is a positive integer N(1<=N<=50000),indicating for the number of given sentences in a program,N lines followed.Each line contains a sentence.The length of a word will not exceed 32.The number of words in a sentence will not exceed 30.
The last line of each test case is a program.The number of words in a program will not exceed 100000.
We won’t be too stupid to ask the same sentence.
Output:
For each test case,output an integer indicating for the frequency that the given sentences appear.
Sample Input:
2
(A)(A)
(B)
(A)(A)(A)(B)
3
(A)(B)(C)
(A)(B)(C)
(A)(B)
(D)(D)
(A)(B)(C)(D)(D)(D)(D)
3
(ABC)
(A)(B)(C)
(ABC)(A)
(ABC)(A)(B)(C)
Sample Output:
3
5
3
Hint:
The solution of the first sample is:
(A)(A)
(A)(A)
(B)
The solution of the second sample is:
(A)(B)(C)
(A)(B)
(D)(D)
(D)(D)
(D)(D)
The solution of the third sample is:
(ABC)
(A)(B)(C)
(ABC)(A)
题解:AC自动机
代码:
暂时没有写出来
相关文章推荐
- 字符串匹配的KMP算法
- 字符串匹配的KMP算法
- POJ-1266/KMP算法/字符串匹配
- 字符串匹配--Sunday算法-C语言实现
- 算法导论第三十二章-字符串匹配-Cpp代码实现
- hihocode的map字符串匹配问题
- ACM学习历程—CodeForces 176B Word Cut(字符串匹配 && dp && 递推)
- 【C/C++】字符串匹配,从主串中删除子串并打印
- 算法——字符串匹配之KMP算法
- 字符串匹配算法——利用有限自动机进行匹配
- CCF 字符串匹配201409-3
- 字符串匹配的KMP算法(简单易懂)
- 字符串匹配之KMP算法
- 字符串匹配
- Java实现 字符串匹配 KMP 算法
- KMP算法---字符串匹配
- 字符串匹配Implement strStr()
- 字符串匹配的KMP算法
- 字符串匹配算法--BF算法
- 字符串匹配算法总结