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 ...
随机推荐
- zip flags 1 and 8 are not supported解决方案
原因是因为使用了mac自带的软件打包成了zip,这种zip包unzip命令无法解压的. 所以解决方案就是使用zip命令进行压缩,zip -r 目标文件 源文件
- java基础篇之Object类
1.Object类是所有类的超类 2.Object类的equals方法 public boolean equals(Object obj) {return (this == obj);} equals ...
- Mac 下 brew的卸载 插件
brew 又叫 Homebrew,是 Mac OSX 上的软件包管理工具,能在 Mac 命令行中方便的安装软件或者卸载软件, 只需要一个命令, 非常方便 brew 类似 ubuntu 系统下的 apt ...
- python中使用requests模块的post()函数时形参 data和json的区别
通常,你想要发送一些编码为表单形式的数据--非常像一个 HTML 表单.要实现这个,只需简单地传递一个字典给 data 参数.你的数据字典在发出请求时会自动编码为表单形式: >>> ...
- 记录linux 生成crash dump文件步骤
执行文件编译时加入-g 命令 例如 g++ -g test.cpp 查看当前系统限制情况 ulimit -a 设置crash dump 文件大小 ulimit -c unlimited unlimit ...
- ELK的安全解决方案 X-Pack(1)
安装 X-Pack 前必须安装 elasticsearch. Kibana.logstash,因为之前安装ELK选择的版本都是5.4.1,所以这次选择X-Pack的版本也要是5.4.1的 第一步:下载 ...
- c++ for_each
#include<iostream>#include<algorithm>#include<vector>using namespace std; int main ...
- prometheus监控插件mysqld_exporter
1,首先需要增加授权 mysql> GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost' IDEN ...
- 基于LSTM + keras 的诗歌生成器
最近在github 上发现了一个好玩的项目,一个基于LSTM + keras 实现的诗歌生成器,地址是:https://github.com/youyuge34/Poems_generator ...
- 【VS开发】fopen 文本文件与二进制文件区别
在学习C语言文件操作后,我们都会知道打开文件的函数是fopen,也知道它的第二个参数是 标志字符串.其中,如果字符串中出现'b',则表明是以打开二进制(binary)文件,否则是打开文本文件. 那么什 ...