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自动机
代码:
暂时没有写出来