CodeForces 832B Round #425 Div2 B Petya and Exam:双指针暴力模拟
2017-07-25 06:01
477 查看
题意:全字符集为‘a’..'z'。现给出一个名叫good的子集,其补集定义为bad,给出模式串s,其中s可能有多个‘?’(可以被替换成任何一个good字符),至多一个‘*’(可以被替换成任意长度的bad串,可以为空),然后给出q次询问,每次询问一个匹配串t能否和s匹配成功。
题解:双指针模拟一下。。。emmm确实这个思路以前都没有尝试过。。WA了这么多次也算学到了一些新东西。
Code:
题解:双指针模拟一下。。。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"); } } }
相关文章推荐
- Codeforces Round #425 (Div. 2) Problem B Petya and Exam (Codeforces 832B) - 暴力
- Codeforces 832-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】66A - Petya and Java(模拟)
- Codeforces #211 (Div. 2) B. Fence (暴力 模拟)
- [几何 模拟退火 || 随机增量法] Codeforces 442E #253 (Div. 1) E. Gena and Second Distance
- Codeforces Round #425 (Div. 2) B. Petya and Exam
- Codeforces 832B - Petya and Exam
- 【CodeForces】66B - Petya and Countryside(递增子串变形题,模拟)
- Codeforces - 277.5 (Div. 2)C - Given Length and Sum of Digits...(模拟 or dfs)
- Codeforces Round #425 (Div. 2) B. Petya and Exam
- Codeforces Round #425 (Div. 2) B. Petya and Exam
- [Codeforces 66C] Petya and File System (模拟)
- 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
- codeforces #233 (Div2) A. Sereja and Dima【模拟】+B. Sereja and Stairs【暴力】