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 ...
随机推荐
- JS——按钮点击事件累加注册问题
最近在工作上遇到一个点击事件累加的问题,为元素添加点击事件效果,但是总是效果失败,最后发现点击事件被执行了多次,上网查了一下,下边就是解决这个问题的几种思路 案列引自 踮起脚尖眺望6 $(" ...
- dsPIC30F 细节点问题不定期更新ing
知识点1 TRISD: I/O 引脚 方向控制 寄存器 (1--input, 0--Output)LATD: I/O 引脚 输出锁存器PORTD: 是双向I/O 端口 备注:LATD = 0x000 ...
- 关于python27和windows系统的中文编码问题
最近想写一个python脚本实现对文件夹中的文件进行批量命名.每个文件对应从txt文档中提取出来的一行,因为文件名是中文,所以涉及到了一些中文编码的问题. 脚本运行环境是win10+python27 ...
- 新手必备的Linux知识
测试人员为什么学习linux? 对于软件测试人员来说,我们测试的任何产品都是基于操作系统.比如我们每天都在使用的QQ软件,它有windows.ios.Android.Mac OS等版本,需要把QQ安装 ...
- 获取当前最顶层的VC
#pragma mark - 获取当前最顶层的ViewController - (UIViewController*)topVC:(UIViewController*)VC { if([VC isK ...
- vb编程中的is是什么意思??
在select case 语句中可以使用关系运算符大于>小于<等于=等关系运算符,需要用关键字IS和TO.用个例子来说明:Private Sub Command1_Click()Dim a ...
- Java使用quartz实现作业调度
在spring boot中使用quartz实现作业调度的功能,简单易用. 什么是Quartz? Quartz是Java领域最著名的.功能丰富的.开放源码的作业调度工具,几乎可以在所有的Java应用程序 ...
- Scrum冲刺阶段5
成员今日完成的任务 人员 任务 何承华 学习后端设计 陈宇 后端设计 丁培辉 学习后端设计 温志铭 日程添加界面设计(后半段设计) 杨宇潇 日程添加界面设计(后半段设计) 张主强 服务器构建学习 成员 ...
- springBoot 使用拦截器 入坑
近期使用SpringBoot 其中用到了拦截器 结果我的静态资源被全部拦截了,让我导致了好久才搞好: 看下图项目结构: 问题描述:上图划红框的资源都被拦截器给拦截了,搞得项目中不能访问:解决问题就是在 ...
- canvas绘制圆图输出图片格式
function drawCircleImage(url, callback) { const canvas = document.createElement('canvas'); const img ...