Codeforces 1221 E Game With String
第一眼以为是SG函数找规律题,然后发现并不是公平游戏。。。。
不过后来想了想,其实这样反而更好做。
这个游戏的一个显然的特性是,任何时候当场上存在长度 ∈[b,a)的块时,Bob必胜。(考虑贪心)
而这题的关键是发现,如果Bob操作时场上还有长度>=2b的块,那么Bob也必胜,因为Bob此时可以构造出一个长度为b的块。
剩下的剩下就是暴力分情况讨论了,看起来是思路已经明确了,但是细节暴多。。。。留给你们自己思考吧w
#include<bits/stdc++.h>
#define ll long long
using namespace std; inline int read(){
int x=0; char ch=getchar();
for(;!isdigit(ch);ch=getchar());
for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
return x;
} bool fl; inline int Get(){
int x=0; char ch=getchar();
for(;ch=='.';ch=getchar()) x++;
if(ch=='\n') fl=1;
return x;
} int Q,a,b,now; inline bool solve(){
a=read(),b=read(); int BA=0,BB=0,DB=0,mx=0;
for(fl=0;!fl;) now=Get(),BA+=now>=a,BB+=now>=b,DB+=now>=b*2,mx=max(mx,now); if(BB>BA) return 0;
if(a>=2*b) return BA==1&&mx<=a+2*b-2;
if(mx>a+4*b-2||DB>1) return 0;
if(DB) return ((BA&1)&&(mx>=3*a||mx<=a+2*b-2))||(!(BA&1)&&mx>=2*a&&mx<=a+3*b-2);
return BA&1;
} int main(){
for(Q=read();Q;Q--) puts(solve()?"YES":"NO");
return 0;
} /*
[b,a)
只要轮到Bob操作的时候,场上存在>=2b的块,那么Bob必胜 ! 1.a>=2b 这样比较惨,只能Alice第一次有填的并且填完之后所有都<b 2.a∈[b+1,2b-1] 正常情况,当且仅当场上只有一块>=2b的且 len<=a+4b-2 */
Codeforces 1221 E Game With String的更多相关文章
- codeforces ~ 1009 B Minimum Ternary String(超级恶心的思维题
http://codeforces.com/problemset/problem/1009/B B. Minimum Ternary String time limit per test 1 seco ...
- 【codeforces 709D】Recover the String
[题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...
- Codeforces Round #617 (Div. 3) String Coloring(E1.E2)
(easy version): 题目链接:http://codeforces.com/contest/1296/problem/E1 题目一句话就是说,两种颜色不同的字符可以相互换位, 问,对这字符串 ...
- codeforces 709D D. Recover the String(构造)
题目链接: D. Recover the String time limit per test 1 second memory limit per test 256 megabytes input s ...
- codeforces 710E E. Generate a String(dp)
题目链接: E. Generate a String time limit per test 2 seconds memory limit per test 512 megabytes input s ...
- Codeforces 710 E. Generate a String (dp)
题目链接:http://codeforces.com/problemset/problem/710/E 加或者减一个字符代价为x,字符数量翻倍代价为y,初始空字符,问你到n个字符的最小代价是多少. d ...
- codeforces 676C C. Vasya and String(二分)
题目链接: C. Vasya and String time limit per test 1 second memory limit per test 256 megabytes input sta ...
- codeforces 598B Queries on a String
题目链接:http://codeforces.com/problemset/problem/598/B 题目分类:字符串 题意:给定一个串,然后n次旋转,每次给l,r,k,表示区间l到r的字符进行k次 ...
- 【Codeforces 1132F】Clear the String
Codeforces 1132 F 题意:给一个串\(S\),问每次删除连续的一段相同字母,最少删几次将原串删空. 思路:考虑区间\(dp\),我们看要删多少次能把\([l,r]\)删空,那么最终答案 ...
随机推荐
- asp.net core-8. 配置的热更新
在asp.net core 发布了以后,在修改配置文件以后不需要重新发布,要实现只需要修改@inject IOptions<WebApplication1.Class> ClassAcce ...
- 阿里云kubernetes集群被xmrig挖矿程序入侵
原因是由于Kubernetes Apiserver不安全配置所致,Apiserver提供了资源操作的唯一入口,并提供认证.授权.访问控制.API注册和发现等机制,所以apiserver的安全至关重要. ...
- 20-MySQL DBA笔记-可扩展的架构
第20章 可扩展的架构 本章将为读者讲述可扩展的架构相关的知识和技术.可扩展的架构意味着这个架构伸缩性好,我们可以用更多的节点来提高吞吐率,而性能(响应时间)不会下降到不可接受的范围.互联网世界飞速发 ...
- (四)Spring Boot之配置文件-多环境配置
一.Properties多环境配置 1. application.properties配置激活选项 spring.profiles.active=dev 2.添加其他配置文件 3.结果 applica ...
- Html 中scroll offset client 总结
HTML精确定位:scrollLeft,scrollWidth,clientWidth,offsetWidth scrollHeight: 获取对象的滚动高度. scrollLeft:设置或获取位于对 ...
- springboot mvc自动配置(三)初始化mvc的组件
所有文章 https://www.cnblogs.com/lay2017/p/11775787.html 正文 在springboot mvc自动配置的时候,获得了DispatcherServlet和 ...
- 基于【 centos7】四 || FastDFS集群+Nginx负载均衡
1. 架构设计 1.1 架构图 FastDFS是用c语言编写的一款开源的分布式文件系统.FastDFS为互联网量身定制,充分考虑了冗余备份.负载均衡.线性扩容等机制,并注重高可用.高性能等指标,使用F ...
- html5+css3 快速学习
http://kuai.qietu.com/books/html5_preview/index.htm#slide1
- Mac下安装和配置Vue项目
题记:学vue有一段时间了,终于今天下定决心每日书写一篇学习笔记.1.访问node.js官网:https://nodejs.org/en/ 下载对应安装包.2.安装完成,在终端输入 : node -v ...
- 2.Redis 入门介绍
A)入门概述: 1.是什么: Redis:REmote Dlctionary Server(远程字典服务器) 是完全开源免费的,用C语言编写的,遵循BSD协议,是一个高性能的(key/value) ...