Codeforces Round #425 (Div. 2) B
来源:互联网 发布:ubuntu中文五笔输入法 编辑:程序博客网 时间:2024/06/07 13:57
题意:告诉你good字母,对于字符串s1*可以变成任意的非good 字符串; ? 可以变成任意的good字母;问给你s2,问是否能从s1变成s2;
思路:判断是否有*,分成2类,然后再分类讨论。
!!!不建议阅读我的代码!!!
#include <bits/stdc++.h>using namespace std;const int maxn=1e5+500;bool vis[500];int main(void){ memset(vis,false,sizeof(vis)); char str[30]; scanf("%s",str); int len=strlen(str); for(int i=0; i<len; i++) { vis[str[i]]=true; } char s[maxn]; int flag=0; scanf("%s",s); len=strlen(s); for(int i=0; i<len; i++) { if(s[i]=='*') { flag=1; break; } } int n ; cin >> n; if(flag==0) { int f=0; for(int k=1; k<=n; k++) { char temp[maxn]; scanf("%s",temp); int len1=strlen(temp); if(len!=len1) { printf("NO\n"); continue; } int f=0; for(int i=0; i<len; i++) { if(s[i]=='?' && vis[temp[i]]==true) continue; if(s[i]!=temp[i]) { f=1; printf("NO\n"); break; } } if(f==0) printf("YES\n"); } } else if(flag==1) { for(int k=1; k<=n; k++) { char temp[maxn]; scanf("%s",temp); int len1=strlen(temp); if(len1>len) { int dlen=len1-len; int i=0,j=0; int f=0; while(j<len1) { if(s[i]=='?' && vis[temp[j]]==true) {i++,j++;continue;} if(s[i]=='*') { for(;j<=i+dlen;++j) { if(vis[temp[j]]==true) { printf("NO\n"); f=1; break; } } j--; if(f==0) {i++,j++;continue;} } if(f==1) break; if(s[i]!=temp[j]) { f=1; printf("NO\n"); break; }i++,j++; } if(f==0) printf("YES\n"); } else if(len1==len) { int f=0; for(int i=0; i<len; i++) { if(s[i]=='*' && vis[temp[i]]==false) continue; if(s[i]=='*' && vis[temp[i]]==true) { f=1; printf("NO\n"); break; } if(s[i]=='?' && vis[temp[i]]==true) continue; if(s[i]!=temp[i]) { f=1; printf("NO\n"); break; } } if(f==0) printf("YES\n"); } else if(len1==len-1) { int i=0,j=0,f=0; while(j<len1) { if(s[i]=='*') i++; if(s[i]=='?' && vis[temp[j]]==true) { i++,j++; continue; } if(s[i]!=temp[j]) { f=1; printf("NO\n"); break; } i++,j++; } if(f==0) printf("YES\n"); } else if(len1 < len-1) printf("NO\n"); } }}
// 改了一个多小时的bug才改出来的。 自己的代码一手bug . 尴尬
阅读全文
0 0
- Codeforces Round #425 (Div. 2)(A+B)
- Codeforces Round #425 (Div. 2) B
- Codeforces Round #425 (Div. 2) B
- 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【模拟】
- Codeforces Round #131 (Div. 2) A B
- Codeforces Round #134 (Div. 2)B. Airport
- Codeforces Round #170 (Div. 2) problem B
- Codeforces Round #173 (Div. 2) Problem B
- Codeforces Round #181 (Div. 2) B. Coach
- Codeforces Round #185 (Div. 2)--A,B
- Codeforces Round #171 (Div. 2) B
- Codeforces Round #169 (Div. 2) B题
- Codeforces Round #188 (Div. 2) B题
- 由socket的accept说开去
- 判断有没有网络 结合一个小案例
- 写给自己看的博客_DoTween
- mongo简单操作
- 面向对象及三大特征讲解(图文)
- Codeforces Round #425 (Div. 2) B
- C++ 参数:复制,引用?
- Web前端——图片压缩与合并
- HDU6043 & 2017 Multi-University Training Contest
- 最长公共上升子序列LCIS
- 学生信息管理系统问题集锦(三)
- 译Combining Markov Random Fields and Convolutional Neural Networks for Image Synthesis
- 安装完pyspark报错
- 03-非关系型数据库种类介绍