UVA 10679 I love Strings!!!(AC自動機)
ProblemG
ILove Strings!!!
Input:Standard Input
Output:Standard Output
TimeLimit: 4 Seconds
Hmmmmmm…………strings again :) Then it must be an easy task for you. You are given with a string S of length less than 100,001, containing only characters from lower and uppercase English alphabet (‘a’-‘z’and ‘A’ – ‘Z’). Then follows q (q < 100) queries where each query contains a string T of maximum length 1,000(also contains only ‘a’-‘z’ and ‘A’ – ‘Z’). You have to determine whether or not T is a sub-string of S.
Input
First line contains aninteger k (k < 10) telling the number of test cases to follow.Each test case begins with S. It is followed by q.After this line there are q lines each of which has a string T as defined before.
Output
For each query print ‘y’if it is a sub-string of S or ‘n’ otherwise followed by a newline. See the sample output below.
Sample Input
2
abcdefghABCDEFGH
2
abc
abAB
xyz
1
xyz
Output for Sample Input
y
n
y
Problemsetter: MohammadSajjad Hossain
題意:
給出一個文本串和若干個模式串,問模式串是否在文本串中出現過。
分析:
簡單粗暴的AC自動機模板題,要注意模式串可能有重復的情況。
/*
*
* Author : fcbruce
*
* Time : Sat 04 Oct 2014 03:30:15 PM CST
*
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include