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 ...
随机推荐
- PyTricks-How to Sort a Python dict
字典的键值排序 import operator # 1表示按照值排序 xs = {"a": 4, "b": 3, "c": 2, " ...
- Protocol Buffers学习笔记
Protocol Buffers学习笔记 1. 简介 Protocol Buffers是google发明的一种数据交换格式,独立于语言,独立于平台.与其他的数据交换格式有所不同,Protocol Bu ...
- Linux 操作memcache命令行
telnet 127.0.0.1 11211 连接 memcache stats 查看 memcache 状态 状态说明: pid memcache服务器的进程ID uptime 服务器已经运行的秒数 ...
- [java]取当前时间
/** * Get current date time * * @return */ private static String getCurrTime() { SimpleDateFormat sd ...
- 进程| 线程 | 阻塞 | 阻塞&非阻塞 和 同步&异步
阻塞&非阻塞 阻塞IO 调用之后一定要等到系统内核完成所有的操作之后才结束,因此它的缺点:CPU等待IO,处理能力得不到充分利用. 非阻塞IO 为了解决阻塞IO带来的一些问题,内核提供了非阻塞 ...
- Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in 解决方案:$sql = ...
- 多位IT专家分享他们离不开的实用工具
本文的 PDF版本可供下载. #1: John Bartow,顾问 John Bartow的工作领域是网络和PC安全,他提供了自己从事的咨询公司, WinHaven Computer Consulti ...
- VLC-DSS搭建直播系统中链路断开影响测试
VLC-DSS搭建直播系统中链路断开影响测试 系统环境搭建如图所示.计算机77上运行VLC从摄像机51上取流,推送给一级DSS服务器30:二级DSS服务器78从一级DSS服务器30上取流转发.(其配置 ...
- mysql删除一条记录
mysql如何删除一条记录 delete from 表名 where 条件 实例: use db1 delete from tb1 where id = 1;
- Flutter之Dio引入和简单的Get/Post请求
先在pubspec.yaml中引入Dio包如图所示 认识Dio库:dio是一个dart的 http请求通用库,目前也是大陆使用最广泛的库,国人开发,完全开源. flutter的插件包管理:学了引入di ...