#SUBPROB. Substring Problem
Substring Problem
String matching is an important problem in computer science research and finds applications in bioinformatics, data mining, pattern recognition, internet security and many more areas.
The problem we consider here is a smaller version of it. You are given a string M and N other strings smaller in length than M. You have to find whether each of these N strings is a substring of M. All strings consist of only alphanumeric characters.
You are required to write a C/CPP code to solve the problem.
Input
Input to the program consists of a series of lines. The first line contains the string M (no more than 100000 characters long). The next line contains an integer N (<1000) the number of query strings. Each of the next N lines contain a string S (each of which is no more than 2000 characters long).
Output
Output should consist of N lines each with a character 'Y' or 'N' indicating whether the string S is a substring of string M or not.
Example
Input: abghABCDE 2 abAB ab</p>Output: N Y
Note: The test data for this problem not only consist of the official test cases from the contest, as well some cases of my own.
A test case was added on 25.7.2010, after rejudging 3 users lose accepted.