#P6727. [COCI 2015/2016 #5] OOP
[COCI 2015/2016 #5] OOP
Description
Given words and patterns, each pattern consists of one * and some lowercase letters. A pattern matches a word if and only if, after replacing * with some string (which can be empty), the pattern and the word can coincide exactly. For each pattern, find how many words it can match.
Input Format
The first line contains two integers .
The next lines each contain a word consisting of lowercase letters.
The next lines each contain a pattern.
The total number of characters read is less than .
Output Format
Output lines. Each line contains the number of words that the corresponding pattern can match.
3 3
aaa
abc
aba
a*a
aaa*
*aaa
2
1
1
5 3
eedecc
ebdecb
eaba
ebcddc
eb
e*
*dca
e*c
5
0
2
Hint
Constraints
For of the testdata, .
For of the testdata, .
Notes
This problem is translated from COCI2015-2016 CONTEST #5 T5 OOP。
Translated by ChatGPT 5
京公网安备 11011102002149号