思路:

模拟。

实现:

 #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. Java基础学习总结(85)——Java中四种线程安全的单例模式实现方式

  2. hadoop full cluster 改为伪分布

    https://hadoop.apache.org/docs/r2.7.6/hadoop-project-dist/hadoop-common/SingleCluster.html#Pseudo-Di ...

  3. Python学习笔记 (2)变量、常量和数据类型

    变量 顾名思义,变量就是一个会变的量,用一个变量名表示,指向内存中一片区域,而指向的区域存的是什么,这个变量就是什么数据类型,和C/C++挺不一样的.变量数据类型可以通过赋值变来变去(这就叫动态语言, ...

  4. [河南省队2012] 找第k小的数

    ★★☆   输入文件:kth.in   输出文件:kth.out   简单对比时间限制:1 s   内存限制:128 MB 题目描述 看到很短的题目会让人心情愉悦,所以给出一个长度为N的序列A1,A2 ...

  5. 我不喜欢的 Rust 特性 (之一) eager drop

    struct Foo; impl Drop for Foo { fn drop(&mut self) { println!("drop"); } } fn main() { ...

  6. go语言使用官方的 log package 来记录日志

    原文:https://www.goinggo.net/2013/11/using-log-package-in-go.html ------------------------------------ ...

  7. School Personal Contest #1 (Codeforces Beta Round #38)---A. Army

    Army time limit per test 2 seconds memory limit per test 256 megabytes input standard input output s ...

  8. Android 自己定义UI圆角button

    Android实际开发中我们一般须要圆角的button,普通情况下我们能够让美工做出来对应的button图片.然后放上去就可以,另外我们能够在布局文件里直接设置,也能够达到一样的效果. 以下解说在布局 ...

  9. Oracle 用户管理(二)

    1    给某人赋予"系统权限"     SQL> grant connect to aobama with admin option     意思是将admin的连接数据库 ...

  10. SOA究竟是个啥

    SOA(Service-Oriented Architecture),中文全称:面向服务的架构. SOA让把系统分离成不同的服务,使用接口来进行数据交互,终于达到整合系统的目的. 专业的词总是让人懵懵 ...