思路:

模拟。

实现:

 #include <iostream>
using namespace std; string a, b;
int m, x, y, ok[]; bool solve()
{
if (y < x - ) return false;
int i = , j = ;
for (; i < x; i++, j++)
{
if (a[i] >= 'a' && a[i] <= 'z')
{
if (a[i] != b[j]) return false;
}
else if (a[i] == '?')
{
if (!ok[b[j] - 'a']) return false;
}
else
{
int tmp = j;
for (; j < tmp + y - x + ; j++)
{
if (ok[b[j] - 'a']) return false;
}
j--;
}
}
return j == y;
} int main()
{
string str;
cin >> str;
int n = str.length();
for (int i = ; i < n; i++)
{
ok[str[i] - 'a'] = ;
}
cin >> a >> m;
x = a.length();
for (int i = ; i < m; i++)
{
cin >> b;
y = b.length();
if (solve()) puts("YES");
else puts("NO");
}
return ;
}

CF832B 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. 832B Petya and Exam

    题意:给你两个串,第一个串里面的字母都是good 字母, 第二个串是模式串,里面除了字母还有?和*(只有一个) ?可以替换所有good字母, *可以替换所有坏字母和空格(可以是多个坏字母!!!这点卡了 ...

随机推荐

  1. 46. Spring Boot中使用AOP统一处理Web请求日志

    在之前一系列的文章中都是提供了全部的代码,在之后的文章中就提供核心的代码进行讲解.有什么问题大家可以给我留言或者加我QQ,进行咨询. AOP为Aspect Oriented Programming的缩 ...

  2. xcode5下取消ARC

    打开你的工程,点击目录的工程文件,最顶端蓝色的,然后选择project下你的工程,还是蓝色那项,然后build Settings,然后往下拉,在Apple LLVM 5.0 - Language - ...

  3. log4j2.xml 的配置 及使用

     log4j2.xml配置 <?xml version="1.0" encoding="UTF-8"?> <Configuration > ...

  4. Windows Server下把BAT批处理注册成服务在后台运行且注销后能正常运行

    批处理有如下特点: 1.登录到当前窗口运行时,如果关闭控制台会连同启动的程序一起关闭. 2.如果是以start /b的形式启动,那么同样也是在控制台关闭后者注销当前窗口也会一起关闭. 3.如果以vbs ...

  5. HDFS2.0之简单总结

    新特性 NameNode支持HA 命名空间支持分区(Federation) 支持ViewFS 支持目录快照 支持权限ACL 支持缓存指定的文件 QJM实现名字节点HA (图片来源互联网) 命名空间分区 ...

  6. Android GIS开发系列-- 入门季(2) MapView与图层介绍

    一.MapView MapView是Arcgis中的最基本的类,与高德地图SDK的MapView的重要性一样.MapView的创建有两种方法,一种是在Layout文件中直接写控件.一种是实例化,Map ...

  7. lua中的闭包小结

    function newCounter() return function() i=i+ return i end end c1=newCounter() print(c1()) print(c1() ...

  8. shell apt install 按tab键自动补全

    insert if [ -f /etc/bash_completion ]; then . /etc/bash_completion fi to ~/.bashrc

  9. [LeedCode OJ]#63 Unique Paths II

     [ 声明:版权全部,转载请标明出处,请勿用于商业用途.  联系信箱:libin493073668@sina.com] 题目链接:https://leetcode.com/problems/uniqu ...

  10. 【HDU1530】【ZOJ1492】Maximum Clique

    Position: http://poj.org/problem?id=3241 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCod ...