cf 832B Petya and Exam
来源:互联网 发布:汉语言文学专业 知乎 编辑:程序博客网 时间:2024/06/05 15:12
点击打开链接
题意:
题意卡我一小时,很不友好,,,,
给你两个串,第一个串里面的字母都是good 字母,
第二个串是模式串,里面除了字母还有?和*(只有一个)
?可以替换所有good字母, *可以替换所有坏字母和空格(可以是多个坏字母!!!这点卡了我很久,也不举一个样例。。。)
然后q次询问,每次给你一个串,问你能否匹配成功,yes or no
题解:
强行模拟,按照规则一个一个匹配就行了,最后如果不能完全匹配就no。,。
#include <bits/stdc++.h>#define ll long longusing namespace std;const int maxn=1e5+10;const int mod=1e9+7;const ll inf=1e17;char a[maxn],b[maxn],s[maxn];int v[200];int main(){ int q; scanf("%s%s",a,b); int n=strlen(a); for(int i=0;i<n;++i) v[a[i]]=1; n=strlen(b); scanf("%d",&q); while(q--){ scanf("%s",s); int len=strlen(s); int o=len-n+1; if(o<0) { puts("NO"); continue; } int i=0,j=0,k; while(i<n){ if(b[i]==s[j]){ i++;j++; }else if(b[i]=='?'&&v[s[j]]){ i++;j++; }else if(b[i]=='*'){ for(k=0;k<o&&j<len;++k,++j) if(v[s[j]]) break; if(k<o) break; i++; }else { break; } } if(i<n||j<len) puts("NO"); else puts("YES"); } return 0;}
阅读全文
1 0
- cf 832B Petya and Exam
- B. Petya and Exam
- cf Petya and Exam(暴力)
- CodeForces 832B Petya and Exam
- codeforces 832B (Petya and Exam)
- CodeForces 832 B. Petya and Exam
- CodeForces-832B Petya and Exam
- B. Petya and Exam【字符串】
- codeforces 832B ——Petya and Exam
- Codeforces 832-B Petya and Exam (模拟)
- B. Petya and Exam(思维)
- codeforces B. Petya and Exam (模拟)
- CodeForces 832B Round #425 Div2 B Petya and Exam:双指针暴力模拟
- CF 66B Petya and Countryside
- Codeforces832B Petya and Exam
- Petya and Exam
- cfRound425B. Petya and Exam
- Codeforces Round #425 (Div. 2)B. Petya and Exam
- MFC中的CListCtrl控件添加行
- 汪国新湖北诗书画院荣誉入选《2017中国文化产业项目重点项目手册》
- ArrayList中elementData为什么被transient修饰?
- HashMap,TreeMap以及LinkedHashMap的区别
- spark 计算引擎
- cf 832B Petya and Exam
- 两分钟学会电子元器件焊接技术!
- 线性查找
- Eclipse-adb指令
- GitLab使用总结
- 通过代理安装pip,及scrapy安装报错记录
- Android 获取当前网速
- 编写可维护的javascript(六):避免使用全局变量
- matlab中的正则表达式