2013年黑龙江省赛C题.Compilation【字符串匹配】


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自动机

代码:

暂时没有写出来

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值