CodeForces 832B Round #425 Div2 B Petya and Exam:双指针暴力模拟
来源:互联网 发布:python.357战损版 编辑:程序博客网 时间:2024/06/12 19:54
题意:全字符集为‘a’..'z'。现给出一个名叫good的子集,其补集定义为bad,给出模式串s,其中s可能有多个‘?’(可以被替换成任何一个good字符),至多一个‘*’(可以被替换成任意长度的bad串,可以为空),然后给出q次询问,每次询问一个匹配串t能否和s匹配成功。
题解:双指针模拟一下。。。emmm确实这个思路以前都没有尝试过。。WA了这么多次也算学到了一些新东西。
Code:
#include<bits/stdc++.h> using namespace std; int main(){ string s; cin>>s; bool f[30]={0}; for(int b=0;b<s.length();b++){ f[(int)s[b]-96]=true; } string ss; cin>>ss; int n; scanf("%d",&n); while(n--){ string s1; cin>>s1; for(int b=0,b1=0;b<ss.length();b++,b1++){ if(ss[b]=='?'){ if(!f[s1[b1]-96]){ printf("NO\n"); break; } }else if(ss[b]=='*'){ int c=0; while(!f[s1[b1]-96]&&b1<s1.length()&&c<s1.length()-ss.length()+1){ b1++;c++; } b1--; }else if(ss[b]!=s1[b1]){ printf("NO\n"); break; } if(b==ss.length()-1) if(b1==s1.length()-1){ printf("YES\n"); }else printf("NO\n"); } } }
阅读全文
0 0
- CodeForces 832B Round #425 Div2 B Petya and Exam:双指针暴力模拟
- Codeforces Round #425 (Div. 2) B. Petya and Exam【模拟】
- codeforces 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 832-B 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 Round #425 (Div. 2) B. Petya and Exam(字符串处理)
- Round #425 (Div. 2)B. Petya and Exam
- B. Petya and Exam
- codeforces 832B ——Petya and Exam
- 使用<span>标签为文字设置单独样式
- 面向任务的对话的键值检索网络(Key-Value Retrieval Networks for Task-Oriented Dialogue)
- java面试之前的复习总结
- CodeForces 832D Round #425 D Misha, Grisha and Underground :LCA求树上路径长度
- oracle数据库的字符集更改
- CodeForces 832B Round #425 Div2 B Petya and Exam:双指针暴力模拟
- Oracle expdp ORA-39006, ORA-39065的解决办法
- Android Service两种启动方式详解(总结版)
- SQL慢查询在Greenplum/Deepgreen中的定位方法
- Oracle的空值处理函数
- CentOS7安装Apache与PHP与新的防火墙配置
- es迁移分片,重置主节点。
- 多线程情况下双重检查锁定问题的分析与优化
- J2SE基础