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 ...
随机推荐
- Qt自定义委托在QTableView中绘制控件、图片、文字
自定义委托,继承于,QStyledItemDelegate类,重载Paint()函数, 1.实现在QTableView中绘制 格式字符串 2.实现在QTableView中绘制进度条 3.实现在QTab ...
- 在使用vagrant访问PHP文件是报错“file not found”,好像是最新的NGINX不能识别document_root,只能改为自己的项目目录/vagrant_data
出现该错误有很多可能,有可能是root配置不对,有可能是fastcgi_param SCRIPT_FILENAME参数不对等. 而本人遇到的也是参数不对,但是是一个比较少人提及的问题,nginx版本不 ...
- Maven 引入外部依赖
pom.xml 的 dependencies 列表列出了我们的项目需要构建的所有外部依赖项. 要添加依赖项,我们一般是先在 src 文件夹下添加 lib 文件夹,然后将你工程需要的 jar 文件复制到 ...
- 数据分析 - Power BI
BI 目的 单表的展示有限很多的时候只能体现现象, 仅仅进行监控级别没问题 但是就数据分析而言实在不够用, 大部分的事情需要多表多图展示才可以通过现象深入挖掘诱因 BI 安装 这里使用 microso ...
- c++自定义数组越异常 ArrayIndexOutOfBoundsException (学习)
#include <iostream> using namespace std; const int DefaultSize = 10; class Array{public: Array ...
- mfc移动文件夹
SHFILEOPSTRUCT FileOp; ZeroMemory((void*)&FileOp,sizeof(SHFILEOPSTRUCT)); FileOp.fFlags = FOF_NO ...
- Linux命令之date
date [选项] [格式] date [-u|--utc|--universal] [MMDDhhmm[[CC]yy][.ss]] date命令根据指定格式显示当前时间或设置系统时间.很多shell ...
- JAVA 基础编程练习题48 【程序 48 加密】
48 [程序 48 加密] 题目:某个公司采用公用电话传递数据,数据是四位的整数,在传递过程中是加密的,加密 规则如下:每位数字都加上 5,然后用和除以 10 的余数代替该数字,再将第一位和第四位交 ...
- glide包管理工具
上一篇文章中我们已经成功的运行了go的代码,这是我们迈出的最基础的一步. 一个项目通常会依赖很多外部的库,当依赖的库比较多的时候,手工管理就会比较麻烦,这个时候就需要包管理工具出场了,帮你管理好所有依 ...
- 【VS开发】fopen 文本文件与二进制文件区别
在学习C语言文件操作后,我们都会知道打开文件的函数是fopen,也知道它的第二个参数是 标志字符串.其中,如果字符串中出现'b',则表明是以打开二进制(binary)文件,否则是打开文本文件. 那么什 ...