Codeforces Round #425 (Div. 2) B. Petya and Exam
来源:互联网 发布:php静态计数器 编辑:程序博客网 时间:2024/05/21 08:49
#include <bits/stdc++.h>using namespace std;bool record[30];int star = -1;const int MAXN = 1e5+10;char pstr[MAXN];int pslen = 0;char str[MAXN];int slen = 0;bool solve(){ if(slen <= pslen-2) return false; if(slen == pslen-1 && star == -1) return false; if(slen != pslen && star == -1) return false; int sl = 0; for(int i = 0; i < star; ++i) { if(pstr[i] != '?') { if(pstr[i] != str[sl]) return false; } else if(!record[str[sl]-'a']) return false; sl++; } int sr = slen-1; for(int i = pslen-1; i > star; --i) { if(pstr[i] != '?') { if(pstr[i] != str[sr]) return false; } else if(!record[str[sr]-'a']) return false; sr--; } while(sl <= sr) { if(record[str[sl++]-'a']) return false; } return true;}int main(){// freopen("in.txt","r",stdin);// freopen("out.txt","w",stdout); ios::sync_with_stdio(false); char ch; while((ch = getchar()) && ch != '\n') record[ch-'a'] = true; while((ch = getchar()) && ch != '\n') { pstr[pslen++] = ch; if(ch == '*') star = pslen-1; } int n; scanf("%d",&n); getchar(); while(n--) { slen = 0; while((ch = getchar()) && ch != '\n') str[slen++] = ch; if(solve()) printf("YES\n"); else printf("NO\n"); } return 0;}
阅读全文
0 0
- 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 Round #425 (Div. 2) B. Petya and Exam
- Codeforces Round #425 (Div. 2) B. Petya and Exam【模拟】
- Petya and Exam(Codeforces Round #425 (Div. 2))
- 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 #212 (Div. 2) B. Petya and Staircases
- Codeforces Round #212 (Div. 2) B. Petya and Staircases
- CodeForces 832B Round #425 Div2 B Petya and Exam:双指针暴力模拟
- CodeForces 832B Petya and Exam
- codeforces B. Petya and Exam (模拟)
- codeforces 832B (Petya and Exam)
- CodeForces 832 B. Petya and Exam
- CodeForces-832B Petya and Exam
- 桥接模式
- jggrid带有参数
- 使用Hawk进行数据存储
- 学习日记
- 小程序事件机制
- Codeforces Round #425 (Div. 2) B. Petya and Exam
- React-Native基础_1.初识React-Native项目
- 约瑟夫环问题,写代码之前重在理解
- 认知神经心理学(各种生理心理效应)
- 大数据可视化常用图表--简单说
- React-Native基础_2.样式Style
- HTTP1.0和HTTP1.1的区别
- java中的map集合(独特的遍历方式)
- 过滤器filter