日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

Petya and Exam

發(fā)布時(shí)間:2024/10/5 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Petya and Exam 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Description
It’s hard times now. Today Petya needs to score 100 points on Informatics exam. The tasks seem easy to Petya, but he thinks he lacks time to finish them all, so he asks you to help with one…

There is a glob pattern in the statements (a string consisting of lowercase English letters, characters “?” and “"). It is known that character "” occurs no more than once in the pattern.

Also, n query strings are given, it is required to determine for each of them if the pattern matches it or not.

Everything seemed easy to Petya, but then he discovered that the special pattern characters differ from their usual meaning.

A pattern matches a string if it is possible to replace each character “?” with one good lowercase English letter, and the character “*” (if there is one) with any, including empty, string of bad lowercase English letters, so that the resulting string is the same as the given string.

The good letters are given to Petya. All the others are bad.

Input
The first line contains a string with length from 1 to 26 consisting of distinct lowercase English letters. These letters are good letters, all the others are bad.

The second line contains the pattern — a string s of lowercase English letters, characters “?” and “" (1?≤?|s|?≤?105). It is guaranteed that character "” occurs in s no more than once.

The third line contains integer n (1?≤?n?≤?105) — the number of query strings.

n lines follow, each of them contains single non-empty string consisting of lowercase English letters — a query string.

It is guaranteed that the total length of all query strings is not greater than 105.

Output
Print n lines: in the i-th of them print “YES” if the pattern matches the i-th query string, and “NO” otherwise.

You can choose the case (lower or upper) for each letter arbitrary.

Examples
Input
ab
a?a
2
aaa
aab
Output
YES
NO
Input
abc
a?a?a*
4
abacaba
abaca
apapa
aaaaax
Output
NO
YES
NO
YES
Note
In the first example we can replace “?” with good letters “a” and “b”, so we can see that the answer for the first query is “YES”, and the answer for the second query is “NO”, because we can’t match the third letter.

Explanation of the second example.

The first query: “NO”, because character “" can be replaced with a string of bad letters only, but the only way to match the query string is to replace it with the string “ba”, in which both letters are good.
The second query: “YES”, because characters “?” can be replaced with corresponding good letters, and character "” can be replaced with empty string, and the strings will coincide.
The third query: “NO”, because characters “?” can’t be replaced with bad letters.
The fourth query: “YES”, because characters “?” can be replaced with good letters “a”, and character “*” can be replaced with a string of bad letters “x”.

#include<stdio.h> #include<string.h> char a[30]; char b[100010]; char c[100010]; int book[200]; int main() {int now=0;scanf("%s",a);int n1=strlen(a);for(int i=0;i<n1;i++){book[a[i]]=1;}scanf("%s",b);int n2=strlen(b);int f=0;for(int i=0;i<n2;i++){if(b[i]=='*'){f=1;break;}}int flag=0;int t;scanf("%d",&t);while(t--){flag=0;now=0;memset(c,0,sizeof(c));scanf("%s",c);int n3=strlen(c);if(f==0&&n2!=n3){printf("NO\n");continue;}if(f==1&&n2-n3>1){printf("NO\n");continue;}for(int i=0;i<n2;i++){if(b[i]=='?'){if(!(book[c[i+now]])){flag=1;break;}}else if(b[i]=='*'){int temp=n3-n2+1;now=temp-1;for(int j=i;j<(i+temp);j++){if(book[c[j]]==1){flag=1;break;}}}else{if(b[i]!=c[i+now]){flag=1;break;}}if(flag==1)break;}if(flag==1){printf("NO\n");}else{printf("YES\n");}} }

總結(jié)

以上是生活随笔為你收集整理的Petya and Exam的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。