codeforces 832B ——Petya and Exam
来源:互联网 发布:长沙哪里有学美工的 编辑:程序博客网 时间:2024/05/17 04:57
先处理出长度的差别,再根据*的位置做判断。因为长度差确定了,*会代替多少个字符也。暴力匹配就行。
#include<iostream>#include<cstdio>#include<cmath>#include<cstring>#include<queue>#include<algorithm>using namespace std;typedef long long int ll;string s,s1,s2;int n;int flag;int main(){ cin>>s>>s1>>n; bool flaggy; int len1=s1.length(); int len2; if(s1.find('*')!=-1) flaggy=true; else flaggy=false; for(int i=0;i<n;i++){ cin>>s2; len2=s2.length(); int ok=1; if(flaggy){ if(len2<len1-1){ printf("NO\n"); continue; } int bound=len2-len1; for(int i=0,j=0;j<len2&&ok;i++,j++){ if(s2[j]==s1[i]) continue; if(s1[i]=='?'&&s.find(s2[j])!=-1) continue; else if(s1[i]=='?') ok=0; if(s1[i]=='*'){ if(bound==-1) j--; else{ for(int k=0;k<=bound&&ok;k++,j++){ if(s.find(s2[j])==-1) continue; else ok=0; } j--; } } else ok=0; } if(ok) printf("YES\n"); else printf("NO\n"); } else{ if(len2!=len1){ printf("NO\n"); continue; } for(int i=0;i<len1&&ok;i++){ if(s1[i]==s2[i]||(s1[i]=='?'&&s.find(s2[i])!=-1)) continue; else ok=0; } if(ok) printf("YES\n"); else printf("NO\n"); } } return 0;}
阅读全文
0 0
- codeforces 832B ——Petya and Exam
- CodeForces 832B Petya and Exam
- codeforces 832B (Petya and Exam)
- CodeForces 832 B. Petya and Exam
- CodeForces-832B Petya and Exam
- Codeforces 832-B Petya and Exam (模拟)
- codeforces B. Petya and Exam (模拟)
- B. Petya and Exam
- cf 832B Petya and Exam
- CodeForces 832B Round #425 Div2 B Petya and Exam:双指针暴力模拟
- Codeforces Round #425 (Div. 2)B. Petya and Exam
- Codeforces Round #425 (Div. 2) B. Petya and Exam
- (字符串匹配)Codeforces Round #425 B. Petya and Exam
- Codeforces Round #425 (Div. 2) B. Petya and Exam
- Codeforces Round #425 (Div. 2) B. Petya and Exam
- Codeforces Round #425 (Div. 2) B. Petya and Exam
- Codeforces Round #425 (Div. 2) B. Petya and Exam【模拟】
- B. Petya and Exam【字符串】
- Activation Function
- [牛客网]错题整理(6)
- keystone知识和理解图
- 使用new来创建动态数组
- Rails 技术栈
- codeforces 832B ——Petya and Exam
- mysql查询报错: ORDER BY clause is not in GROUP BY..this is incompatible with sql_mode=only_full_group_by
- PhotosUI 取图片为nil问题
- turtle库绘制树
- 三分钟了解比特币期权
- volatile不能保证程序执行的原子性以及只能一定程度上保证有序性
- jvm 之 对象的创建
- 深入理解Java类加载器(ClassLoader)
- mybatis 模糊查询