wa一万次难受。

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
#define max_n 100010
char a[max_n],b[max_n],c[max_n];
int d[]; int main()
{
int n,res=;
memset(d,,sizeof(d));
scanf("%s",a);
getchar();
for(int i=;i<strlen(a);i++)
{
d[a[i]]=;
}
scanf("%s",b);
getchar();
for(int i=;i<strlen(b);i++)
{
if(b[i]=='*')
{
res++;
break;
}
}
int len1=strlen(b);
scanf("%d",&n);
while(n--)
{
bool flag=true;
memset(c,,sizeof(c));
scanf("%s",c);
int cnt=;
int len2=strlen(c);
int len=max(len1,len2);
int ans=abs(len1-len2);
if(res== && ans!=) //防hack,加了几个特判
{
printf("NO\n");
continue;
}
if(res== && len1-len2>=)
{
printf("NO\n");
continue;
}
for(int i=;i<len1;i++)
{
if(b[i]=='?')
{
if(d[c[i+cnt]]!=)
flag=false;
}
else if(b[i]=='*')
{
for(int j=i;j<=len2-len1+i;j++)
{
if(d[c[j]])
{
flag=false;
break;
}
}
cnt=len2-len1;
}
else
{
if(b[i]!=c[i+cnt])
flag=false;
}
// printf("%c %c %d\n",b[i],c[i+cnt],cnt);
if(!flag) break;
}
if(flag) printf("YES\n");
else printf("NO\n");
}
return ;
}

codeforce B. Petya and Exam的更多相关文章

  1. CodeForces832-B. Petya and Exam

    补的若干年以前的题目,水题,太菜啦_(:з」∠)_    B. Petya and Exam time limit per test 2 seconds memory limit per test 2 ...

  2. Codeforces Round #425 (Div. 2) B. Petya and Exam(字符串模拟 水)

    题目链接:http://codeforces.com/contest/832/problem/B B. Petya and Exam time limit per test 2 seconds mem ...

  3. CodeForces 832B Petya and Exam

    B. Petya and Exam time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  4. Codeforces Round #425 (Div. 2) B - Petya and Exam

    地址:http://codeforces.com/contest/832/problem/B 题目: B. Petya and Exam time limit per test 2 seconds m ...

  5. Codefroces 832B Petya and Exam

    B. Petya and Exam time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  6. E - Petya and Exam CodeForces - 832B 字典树+搜索

    E - Petya and Exam CodeForces - 832B 这个题目其实可以不用字典树写,但是因为之前写过poj的一个题目,意思和这个差不多,所以就用字典树写了一遍. 代码还是很好理解的 ...

  7. B. Petya and Exam

    B. Petya and Exam 题目链接 题意 给你一串字符,在这个串中所有出现的字符都是\(good\)字符,未出现的都是\(bad\)字符, 然后给你另一串字符,这个字符串中有两个特殊的字符, ...

  8. Codeforces Round #425 (Div. 2) Problem B Petya and Exam (Codeforces 832B) - 暴力

    It's hard times now. Today Petya needs to score 100 points on Informatics exam. The tasks seem easy ...

  9. codeforce 886C Petya and Catacombs (map,思路)

    突然发现百度不到这题的单独题解(果然是因为这是水题么),那我就来写一个了~ 先把题给贴了. C. Petya and Catacombs time limit per test 1 second me ...

随机推荐

  1. AcFun 的视频架构演化实践——阅读心得

    视频的核心技术栈 AcFun 弹幕视频网(acfun.tv)是中国最早上线的弹幕视频网站,也是最具影响力的弹幕视频平台.“AcFun”原取意于“AnimeComic Fun”.自2007年6月6日成立 ...

  2. iTerm2 + oh my zsh +agnoster

    安装iTerm2 iTerm2官方下载地址 http://www.iterm2.com/downloads.html 安装Oh My Bash 1.通过cat /etc/shells命令可以查看当前系 ...

  3. Flutter子组件调用父组件方法修改父组件参数

    子组件调用父级组件方法的主要实现是父组件给子组件传入一个方法,然后在子组件中调用父级方法来修改父级的参数.看一下效果图 父级组件实现 在父级组件中写一个_editParentText的方法来修改组件中 ...

  4. shell 變數

    echo $? 上个命令的退出状态,或函数的返回值. ref: http://c.biancheng.net/cpp/view/2739.html

  5. Facebook币Libra学习-6.发行属于自己的代币Token案例(含源码)

    在这个简短的概述中,我们描述了我们在eToro标记化资产背后实施技术的初步经验,即MoveIR语言中的(eToken),用于在Libra网络上进行部署. Libra协议是一个确定性状态机,它将数据存储 ...

  6. RecyclerView下拉刷新和上拉加载更多实现

    RecyclerView下拉刷新和上拉加载更多实现 转 https://www.jianshu.com/p/4ea7c2d95ecf   在Android开发中,RecyclerView算是使用频率非 ...

  7. Visual Studio2013的C语言编译器对C99标准的支持情况

    Visual Studio2013终于开始比较良好地支持C99特性了.在此之前,如果用C语言写代码的话,变量名都需要放到函数体的前面部分,代码写起来十分别扭. 而Visual Studio2013中的 ...

  8. Qt编写自定义控件26-平铺背景控件

    一.前言 平铺背景控件,主要的应用场景是作为画布出现,黑白相间的背景图,然后上面可以放置图片图形等,使得看起来更美观,比如PS软件新建图层以后的背景,FireWorks软件新建画布以后的透明背景,IC ...

  9. java+上传大文件

    在Web应用系统开发中,文件上传和下载功能是非常常用的功能,今天来讲一下JavaWeb中的文件上传和下载功能的实现. 先说下要求: PC端全平台支持,要求支持Windows,Mac,Linux 支持所 ...

  10. kubernetes之StatefulSet部署zk和kafka

    前提 至少需要三个node节点,否则修改亲和性配置 如果外部访问,需要自己暴露 需要有个storageClass,这样做的原因是避免手动创建pv了 部署zk和kafka 参考: https://www ...