codeforce B. Petya and Exam
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的更多相关文章
- CodeForces832-B. Petya and Exam
补的若干年以前的题目,水题,太菜啦_(:з」∠)_ B. Petya and Exam time limit per test 2 seconds memory limit per test 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 ...
- CodeForces 832B Petya and Exam
B. Petya and Exam time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- 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 ...
- Codefroces 832B Petya and Exam
B. Petya and Exam time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- E - Petya and Exam CodeForces - 832B 字典树+搜索
E - Petya and Exam CodeForces - 832B 这个题目其实可以不用字典树写,但是因为之前写过poj的一个题目,意思和这个差不多,所以就用字典树写了一遍. 代码还是很好理解的 ...
- B. Petya and Exam
B. Petya and Exam 题目链接 题意 给你一串字符,在这个串中所有出现的字符都是\(good\)字符,未出现的都是\(bad\)字符, 然后给你另一串字符,这个字符串中有两个特殊的字符, ...
- 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 ...
- codeforce 886C Petya and Catacombs (map,思路)
突然发现百度不到这题的单独题解(果然是因为这是水题么),那我就来写一个了~ 先把题给贴了. C. Petya and Catacombs time limit per test 1 second me ...
随机推荐
- sh: 1: Syntax error: Bad fd number
Start on Ubuntu 6.10,Using dash default(theDebian Almquist Shell) instead bash(the GNUBourne-Again S ...
- Hype-v创建服务器实例
1.创建虚拟交换机,如下图所示(虚拟交换机,只需要创建一次,后面增加服务器实例的时候,只需要选择这个虚拟交换机就可以了,不用每次都创建) 2.服务器主网络共享给虚拟交换机,如下图所 3.虚拟交换机的I ...
- C++的精髓——代码复用、接口复用
C++的精髓——代码复用.接口复用 在另一篇文章中提到C++三大特点的核心概括,也写在这里吧.封装:信息隐藏继承:代码复用多态:面向对象C++并不是面向对象,它包容多种编程思想,如面向过程,面向对象, ...
- app微信支付的集成步骤
1.引用地址 //微信支付 compile 'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:+' 2.注册 private IWXAPI api ...
- C之静态内存和动态内存
静态内存: * 自动申请,自动释放* 大小固定,内存空间连续* 从栈上分配的内存叫静态内存 动态内存: * 程序员自己申请 * new/malloc* 大小取决于虚拟内存的大小,内存空间不连续* ja ...
- vue+七牛云 截图工具
1.安装:npm install vue-cropper 2.引入:import VueCropper from 'vue-cropper' Vue.use(VueCropper) <templ ...
- 总是访问到tomcat首页解决
部署代码后总是访问到tomcat首页解决 没有把路径写全 访问:养成带上绝对路径的习惯,否则总是访问到tomcat的首页 http://114.116.65.232:8085/ssoserver/
- stm32第一章cortex-M3处理器概述
处理器特点 哈弗结构3级流水线内核 实现Thumb-2指令集,告别切换32位的arm指令和16位的Thumb指令,优化性能和代码密度 结合可配置的嵌套向量中段控制器Nvic,提供非屏蔽中断NMI和32 ...
- WordPress自定义菜单和修改去除多余的css
这里主要是用于模板制作的,一般前端已经写好了,我们只要将前端的内容套用WordPress后台就可以了. 所以我们在模板制作过程中,需要自定义WordPress菜单. 在functions.php文件中 ...
- html5 商品分类页面效果zepto
点击左边容器条目,右边列表对应的内容置顶显示,滑动右边的列表,左边容器的对应的标题高亮显示. 效果图如下: 代码: <!doctype html> <html> <hea ...