#P3167. [CQOI2014] 通配符匹配

    ID: 2216 远端评测题 1000ms 125MiB 尝试: 3 已通过: 1 难度: 7 上传者: 标签>字符串2014重庆各省省选哈希,HASHAC 自动机

[CQOI2014] 通配符匹配

Description

Almost all operating systems' command-line interfaces (CLI) support wildcard matching for filenames to help users. The two most common wildcards are: an asterisk (*), which matches any sequence of characters of length 0 or more; and a question mark (?), which matches exactly one arbitrary character. You are to write a program that, given a list of filenames and a pattern string containing wildcards, determines which files can be matched.

Input Format

The first line is a string consisting of lowercase letters and the above wildcards. The second line contains an integer nn, indicating the number of files. The next nn lines each contain a string consisting only of lowercase letters, representing the list of filenames.

Output Format

Output nn lines, each being YES or NO, indicating whether the corresponding file can be matched by the pattern.

*aca?ctc
6
acaacatctc
acatctc
aacacatctc
aggggcaacacctc
aggggcaacatctc
aggggcaacctct
YES
YES
YES
YES
YES
NO

Hint

For 100%100 \% of the testdata:

  • String length does not exceed 100000.
  • 1n1001 \le n \le 100.
  • The number of wildcards does not exceed 10.

Translated by ChatGPT 5