Ghosh Birthday Party
All submissions for this problem are available.
Ghosh had shortlisted names of friends to invite for his nephew's birthday. However, when he was away, his nephew messed up and saved all the names in a single string S (1<=S<=100,000) and also added random letters between the names. Now, Ghosh does not remember which friends he had decided to invite, and hence does not know how many pastries to order. Your task is to help Ghosh, and of all the names he calls out, you have to mention how many were present in the invitation list.
Note: If name A happens to be a sub-string of name B, and name B is present in S, both names will be counted in the total.
First line contains the string S. Second line contains number of test cases T(1<=T<=50,000).
For each test case, there is a line containing the name N (number of characters varies from 1 to 50) to be searched in the string S. Both S and N are case sensitive. There will be only one S on which all searches will occur.
Output is the number of friends that were present in the list
Input: GASAGRAJUUYNDGANIKETOIUS 3 RAJU ANITA ANIKET Output: 2
First line of the input is the string S that was created by Ghosh's nephew. Next line is the number of names that Ghosh calls out. Further lines are the names that Ghosh calls out.
Out the 3 names, only RAJU and ANIKET are present in the string S. Hence, output is 2.
|Time Limit:||0.137931 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.