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字母, *可以替换所有坏字母和空格(可以是多个坏字母!!!这点卡了 ...
随机推荐
- [luoguP1736] 创意吃鱼法(DP)
传送门 f[i][j][0] 表示从右下角到左上角,以(i,j)为起点能延伸的最大值 f[i][j][1] 表示从左下角到右上角,以(i,j)为起点能延伸的最大值 up[i][j] 表示(i,j)上面 ...
- JRobin cpu 和 磁盘
https://blog.csdn.net/li_zhongnan/article/details/3754053 https://blog.csdn.net/li_zhongnan/article/ ...
- Minimal string 栈 贪心
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- NOIP2011 提高组合集
NOIP 2011 提高组合集 D1 T1 铺地毯 模拟,题目让你干啥你就干啥 #include <iostream> #include <cstdio> using name ...
- LVS 源代码分析
http://blog.chinaunix.net/uid/11207493.html http://zh.linuxvirtualserver.org/blog/3309
- eclipse 安装egit插件
一.Eclipse上安装GIT插件EGit Eclipse的版本eclipse-java-helios-SR2-win32.zip(在Eclipse3.3版本找不到对应的 EGit插件,无法安装) E ...
- 今天又学到了一个很重要的公式,(a+b)^n,组合数的求和,牛逼,为自己鼓掌👏
另外还有: C(n, 0) + ... + C(n, n) = 2^n 其实从上面的二项式定理,也可以推导出来的.
- influxDB系列(二)--查看数据库的大小
google 搜索了好多文档,终于发现了这个靠谱的回答. https://groups.google.com/forum/#!topic/influxdb/I5eady_Ta5Y You can se ...
- Ajax异步方式实现登录与參数的校验
登录代码 这个是使用Bootstrap3的组件功能实现的 <div class="login_con_R"> <h4>登录</h4> <F ...
- 行香子·过尽千山
<行香子·过尽千山> 文/天地尘埃2020 过尽千山.水瘦山寒. 思来路.地咽天玄. 千金散尽,欲补穹天. 但孟春暖,仲春炫.暮春喧. 三皇五帝,魏武挥鞭. 朴无欲.衡玉玑璿. 金生丽水, ...