Oop
의견: 0
\(5^{th}\) round, January \(16^{th}\) 2016
Little Matej is solving an OOP (Obje\(ct-or\)iented programming) laboratory exercise and he’s having
trouble with solving one subtask.
He is given a set that contains \(N\) words. He is also given \(Q\) queries where each query is one pattern. A
pattern consists of a single character “” and lowercase letters of the English alphabet. For example,
“”, “k\(ul*to\)”, “ana”.
A pattern is said to cover a word if such an array of letters (which can be empty) exists that, when
replacing the character ‘’, the pattern and the word become completely identical. It is necessary to
output how many words each pattern covers.
The first line of input contains two integers \(N\) and \(Q\) (1 ⩽N, Q ⩽100 000).
Each of the following \(N\) lines contains a word that consists of lowercase letters of the English alphabet.
Each of the following \(Q\) lines contains a pattern for which you need to output how many words from
the first set it covers.
The total number of characters will be less than 3 000 000.
SCORING
In test cases worth 40% of total points, it will additionally hold 1 ⩽N, Q ⩽1000.
Output \(Q\) lines, the \(k\)^{th} line containing the number of words that the \(k\)^{th} pattern covers.
3 3
aaa
abc
aba
a*a
aaa*
*aaa
5 3
eedecc
ebdecb
eaba
ebcddc
eb
e*
*dca
e*coutput
2
1
1
5
0
2평가 및 의견
Oop
Log in to rate problems.
아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.
풀이 제출
Oop