1108 : Finding Words
- 时间限制Time Limit
- 2 秒Sec
- 内存限制Memory Limit
- 512 兆MB
- 提交次数Submitted
- 143 次Times
- 通过次数Solved
- 27 次Times
| 比对Compare | token 相同即通过。中间的空格、制表符、换行可多可少。Matching tokens pass. Extra spaces, tabs, or newlines between them are ignored. |
|---|---|
| 不同则错Differs | token 个数或内容不同即错误。23 与 2 3、02 与 2、2.0 与 2 均视为不同。A different token count or value is wrong. 23 vs 2 3, 02 vs 2, and 2.0 vs 2 all differ. |
| 输入Input | 标准输入,格式见题面。Standard input; format as in the statement. |
| 输出Output | 标准输出。Standard output. |
| 时间与内存Time and memory | 记这一份程序的 CPU 时间和内存峰值。题目上的时间限制、内存限制就是这一份的上限。The record is this program’s CPU time and peak memory. The limits on the problem apply to this one run. |
题目描述Description
Bob is writing his thesis, and he wants to use some advanced vocabulary. Unfortunately, he has forgotten how to spell some of the words. He just remember some characters at the beginning and ending. Now he need your help to find all the possible words.
Bob will give you a query which consists of lowercase letters and one asterisk(*), The asterisk could be replaced by zero or more letters. You need to find all the words which match the query. For example, if the query is “a*nd”, then you may tell him the words “and”, “append”, “attend”, etc.
输入格式Input
There is only one test case. The first line contains the number of words n(1 ≤ n ≤ 105) in the dictionary. Each of the following n lines contains a word which consists of lowercase letters. The length of each word is not more than 30. The next line contains the number of queries q(1 ≤ q ≤ 105). Each of the following q lines contains a query which consists of zero or more lowercase letters and one asterisk. The length of each query is not more than 30.
输出格式Output
For each query, print the number of words in the dictionary which match the query.
样例Sample
出题Author
Staginner