Codeforces Round #425 (Div. 2)
A
题意:给你n根棍子,两个人每次拿m根你,你先拿,如果该谁拿的时候棍子数<m,这人就输,对手就赢,问你第一个拿的人能赢吗
代码:
#include<stdio.h>
#define ll long long
using namespace std;
ll n,m;
int main()
{
while(~scanf("%I64d%I64d",&n,&m))
{
ll r=n/m;
if(r%2==1)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
B:字符串,暴力
题意:给你的第一串里的字符都是好的,除开这个字符以外的所有小写字符都是坏了,然后再给你一个待匹配的的串,这个串中的’?‘可以替换成任何一个好的小写字符,‘*’表示可以替换成一个空的字符串或是一个全部由坏的小写字符组成的字符串(长度可以为1,也可以大于1)。然后下面开始询问,输入一个串问能不能由上面的串得来,可以就输出YES,否则输出NO
几组样例吧
abc
a*?b
3
acb
YES
aicb
YES
ab
NO
k
aaa
1
aa
NO
这个题有个bug我觉得因为对于下面的数据
a
*?
2
a
NO
ba
NO
这里应该都输出YES才对,但是我的代码在codeforces上过了,应该第二个字符串必须包含小写字符吧。
代码:
#include<stdio.h>
#include<string.h>
using namespace std;
char a[30];
int vis[30];
char b[111000];
int n;
char c[111000];
int main()
{
while(~scanf("%s",a))
{
memset(vis,0,sizeof(vis));
for(int i=0; a[i]; i++)
vis[a[i]-'a']=1;
scanf("%s",b);
scanf("%d",&n);
int ans=0;
for(int i=0;b[i];i++)
if(b[i]=='*')
ans++;
for(int l=0; l<n; l++)
{
int flag=0;
scanf("%s",c);
int x=strlen(b);
int y=strlen(c);
int i=0,j=0;
if(ans==0&&y!=x)
flag=1;
if(ans==1&&y<x-1)
flag=1;
else
while(i<x&&j<y)
{
if(b[i]==c[j])
{
i++;
j++;
continue;
}
else if(b[i]=='?')
{
if(vis[c[j]-'a']==0)
{
flag=1;
break;
}
else
{
i++;
j++;
continue;
}
}
else if(b[i]=='*')
{
if(y==x-1)
{
i++;
continue;
}
else
{
for(int k=j; k<=j+y-x; k++)
{
if(vis[c[k]-'a']==1)
{
flag=1;
break;
}
}
if(flag==1)
break;
i++;
j=j+y-x+1;
}
}
else
{
flag=1;
break;
}
}
if(flag==1)
printf("NO\n");
else
printf("YES\n");
}
}
return 0;
}
Codeforces Round #425 (Div. 2)的更多相关文章
- Codeforces Round #425 (Div. 2)C
题目连接:http://codeforces.com/contest/832/problem/C C. Strange Radiation time limit per test 3 seconds ...
- Codeforces Round #425 (Div. 2) Problem D Misha, Grisha and Underground (Codeforces 832D) - 树链剖分 - 树状数组
Misha and Grisha are funny boys, so they like to use new underground. The underground has n stations ...
- Codeforces Round #425 (Div. 2) Problem C Strange Radiation (Codeforces 832C) - 二分答案 - 数论
n people are standing on a coordinate axis in points with positive integer coordinates strictly less ...
- 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 ...
- Codeforces Round #425 (Div. 2) Problem A Sasha and Sticks (Codeforces 832A)
It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day h ...
- 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 Round #425 (Div. 2))——A题&&B题&&D题
A. Sasha and Sticks 题目链接:http://codeforces.com/contest/832/problem/A 题目意思:n个棍,双方每次取k个,取得多次数的人获胜,Sash ...
- 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 ...
- Codeforces Round #425 (Div. 2) C - Strange Radiation
地址:http://codeforces.com/contest/832/problem/C 题目: C. Strange Radiation time limit per test 3 second ...
随机推荐
- innodb 体系结构(后台进程)
一.后台进程(innodb 1.0.x以前的) 1.master thread master thread具有最高的线程优先级别,其内部由多个循环(loop)组成:主循环(loop).后台循环(bac ...
- VSCode下调试mocha测试用例
之前使用tape做Node.js的单元测试,最方便一条就是使用它就和自己写个控制台应用程序测试一样,控制起来比较灵活,直接用VSCode进行调试也比较方便.然而tape输出中文字符总是乱码,想了很多办 ...
- Qt4.8.6开发WinCE 5.0环境搭建
Qt-Wince5.0开发环境介绍 1.Windows7SP1 64 2.vs2008,以及sp1补丁 3.编译qt-everywhere-opensource-src-4.8.6.zip 4.qt- ...
- Linux screenshot
一.简介 linux下的三个截图软件
- Luogu3579 Solar Panels
整除分块枚举... 真的没有想到会这么简单. 要使一个数 \(p\) 满足 条件, 则 存在\(x, y\), \(a<=x \times p<=b\ \&\&\ c< ...
- Numpy安装
Python官网上的发行版是不包含Numpy模块的. 1.使用已有的发起行版本 对于许多用户,尤其是在Windows上,最简单的方法就是下载以下的Python发行版,他们包涵了所有的关键包(包括Num ...
- oracle 查询clob 列时 很慢 , 未解决
今天查询一张表 ,这张表有一个clob 列 select * from tableName : 很卡.. 难道是查询的太多? select * from tableName where rowN ...
- 【NIFI】 Apache NiFI 集群搭建
NiFI 集群介绍 NiFi集群架构 NiFi采用Zero-Master Clustering范例.集群中的每个节点对数据执行相同的任务,但每个节点都在不同的数据集上运行.其中一个节点自动选择(通过A ...
- new-xml-data
~<cyfxml> <hhis> <hhi name="大货系统" is-sub-item-folder="True" is-su ...
- day 35 线程
内容回顾 # 互斥锁 #在同一个进程中连续锁多次 #进程的数据共享 #进程之间可以共享数据 #提供共享数据的类是Manager #但是它提供的list|dict 这些数据类型 #针对+= -= *= ...