Search Multiple Strings
Given a long text
, you are asked to check for each of the strings if they are a substring of
Pro Tip If you need to increase the probability that the two substrings are actually equal to each other using hashes, you might consider calculating several hashes using different prime numbers and different modulo numbers to make sure the hashes are actually equal. This way, you’d compare a tuple of hashes to another tuple of hashes.
The first line of the input contains the text
t(1 ≤ |t| ≤ ).
The next line contains a single integer
n(1 ≤ n ≤ ).
nlines contain strings
(1 ≤ || ≤ min(50, |t|)).
The program should print
nlines. Each line should contain
Yesif the corresponding string is a substring of
habababohabo 3 ba yoyo ababoha
Yes No Yes
Time limit: 5 seconds
Memory limit: 1000 MB
Output limit: 1 MB