CF832B Petya and Exam
思路:
模拟。
实现:
#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的更多相关文章
- 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 ...
- 832B Petya and Exam
题意:给你两个串,第一个串里面的字母都是good 字母, 第二个串是模式串,里面除了字母还有?和*(只有一个) ?可以替换所有good字母, *可以替换所有坏字母和空格(可以是多个坏字母!!!这点卡了 ...
随机推荐
- A^B Mod C
基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 给出3个正整数A B C,求A^B Mod C. 例如,3 5 8,3^5 Mod 8 = 3. Input 3个正整 ...
- 【Chrome】Chrome浏览器怎么查看版本信息
第一步,打开Chrome浏览器 第二步,弹出浏览器主界面 第三步,点击右上按钮(三横杠) 第四步,下拉中选择“关于” 第五步,弹出窗口,可以看到版本信息 第二种方法: 第六步,也可以通过地址栏里输入命 ...
- jquery simple modal
窗体API定义丰富,而且使用也很容易上手.官方地址:http://www.ericmmartin.com/projects/simplemodal/从官方下载插件,在文件中引用<script t ...
- 这篇讲angular 的$q的讲得不错
原文: https://segmentfault.com/a/1190000000402555 ---------------------------------------------------- ...
- group & user
例子 groupadd test 创建test用户组 useradd user1 创建user1用户 passwd user1 设置user1的密码 useradd user2 ...
- C++ Sleep Function 使用方法 Sleep(-1)
<span style="font-size:18px;">//==================================================== ...
- Centos 7 nginx-1.12.0 配置学习(一)
[root@bogon nginx]# vim nginx.conf #user nobody; #运行用户 worker_processes ; #启动进程,通常设置成和cpu核心数相等 #全局错误 ...
- Android Studio最新配置教程2016
http://blog.csdn.net/wen_demo 一.Android studio 基本简单介绍 1.Android studio和Eclipse的差别: 1.Studio中有Project ...
- BestCoder Round #61 (div.2) C.Subtrees dfs
Subtrees 问题描述 一棵有N个节点的完全二叉树,问有多少种子树所包含的节点数量不同. 输入描述 输入有多组数据,不超过1000组. 每组数据输入一行包含一个整数N.(1\leq N\leq ...
- 大神是如何装逼的 之 vim插件使用taglist和nerdtree
本文转载自:http://blog.csdn.net/yaoxingshuai/article/details/51385332 本文主要讲述如何在vim下配置taglist,nerdtree(看代码 ...