codeforce B. Petya and Exam
2017-08-09 16:42
344 查看
wa一万次难受。
#include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; #define max_n 100010 char a[max_n],b[max_n],c[max_n]; int d[1010]; int main() { int n,res=0; memset(d,0,sizeof(d)); scanf("%s",a); getchar(); for(int i=0;i<strlen(a);i++) { d[a[i]]=1; } scanf("%s",b); getchar(); for(int i=0;i<strlen(b);i++) { if(b[i]=='*') { res++; break; } } int len1=strlen(b); scanf("%d",&n); while(n--) { bool flag=true; memset(c,0,sizeof(c)); scanf("%s",c); int cnt=0; int len2=strlen(c); int len=max(len1,len2); int ans=abs(len1-len2); if(res==0 && ans!=0) //防hack,加了几个特判 { printf("NO\n"); continue; } if(res==1 && len1-len2>=2) { printf("NO\n"); continue; } for(int i=0;i<len1;i++) { if(b[i]=='?') { if(d[c[i+cnt]]!=1) flag=false; } else if(b[i]=='*') { for(int j=i;j<=len2-len1+i;j++) { if(d[c[j]]) { flag=false; break; } } cnt=len2-len1; } else { if(b[i]!=c[i+cnt]) flag=false; } // printf("%c %c %d\n",b[i],c[i+cnt],cnt); if(!flag) break; } if(flag) printf("YES\n"); else printf("NO\n"); } return 0; }
相关文章推荐
- Codeforces Round #425 (Div. 2) B. Petya and Exam
- codeforce 851 B Arpa and an exam about geometry(思路)
- Codeforces Round #425 (Div. 2) B. Petya and Exam
- Codeforces Round #425 (Div. 2) B. Petya and Exam【模拟】
- CodeForces Petya and Exam
- codeforce 66E - Petya and Post(dp+减少冗余)
- codeforce 66E - Petya and Post(dp+减少冗余)
- Codeforces 832B - Petya and Exam
- codeforce 766D Mahmoud and a Dictionary 带权并查集
- CodeForce 526B Om Nom and Dark Park(dp + 递归)
- CodeForces 832B Round #425 Div2 B Petya and Exam:双指针暴力模拟
- Codeforces Round #425 (Div. 2) B. Petya and Exam
- CodeForces 832B Petya and Exam
- codeforceB. Mishka and trip
- Codeforce - 361 - B. Levko and Permutation
- Petya and Staircases CodeForces - 362B(思维)
- codeforce 766D Mahmoud and a Dictionary 带权并查集
- codeforce C - Vasya and Robot
- codeforce_Diplomas and Certificates_水
- Codeforce - 573B - Bear and Blocks