#P2908. [USACO08OPEN] Word Power S
[USACO08OPEN] Word Power S
Description
Farmer John wants to evaluate the quality of the names of his cows. Each name is a string with no more than 1000 characters, all of which are non-blank.
He has created a set of 'good' strings (no longer than 30 characters and fully non-blank). If the sequence letters of a cow's name contains the letters of a 'good' string in the correct order as a subsequence (i.e., not necessarily all next to each other), the cow's name gets 1 quality point.
All strings is case-insensitive, i.e., capital letters and lower case letters are considered equivalent. For example, the name contains the letters of , , , and in the correct order, but not or . Help Farmer John determine the number of quality points in each of his cow's names.
Input Format
-
Line : Two space-separated integers: and .
-
Lines : Line contains a string that is the name of the ith cow.
-
Lines : Line contains the ith good string.
Output Format
- Lines : Line contains the number of quality points of the ith name.
5 3
Bessie
Jonathan
Montgomery
Alicia
Angola
se
nGo
Ont
1
1
2
0
1
Hint
There are 5 cows, and their names are , , , , and . The 3 good strings are , , and .
contains , contains , contains both and , contains none of the good strings, and contains .
京公网安备 11011102002149号