传送门

文章目录

  • 题意:
  • 思路:

题意:

思路:

我们将每一段...拿出来看成若干段,将其分成以下四种情况:
(1)len<b(1)len<b(1)len<b
(2)b≤len<a(2)b\le len<a(2)b≤len<a
(3)a≤len<2∗b(3)a\le len<2*b(3)a≤len<2∗b
(4)len≥2∗b(4)len\ge 2*b(4)len≥2∗b
我们依次考虑这四种线段。
(1)(1)(1)首先线段111是无用线段,不需要考虑。
(2)(2)(2)线段222只能由后手操作,如果存在线段222,那么后手必胜。
证明:因为先抛去线段222,使用其他的线段进行游戏,结果无非两个,先手不能操作和后手不能操作。先手不能操作那么后手必胜,后手不能操作的时候说明线段已经用光了,这个时候拿出线段222来使得后手仍能操作,后手必胜。
(3)(3)(3)线段333二者只能操作一次,那么如果只存在线段333的话,由偶数段线段333的时候后手必胜,有奇数段线段333的时候先手必胜。
比较显然,不加以证明。
(4)(4)(4)线段444如果存在至少两条的时候,后手必胜。
证明:由于后手可以从线段444中截出来一段线段222,所以先手动的时候最多能操作一个线段444来使得其不能被分出来线段222,所以如果有至少两个线段444那么后手必胜。
现在讨论只有一个线段444的时候怎么办。
首先先手肯定是要操作线段444的,不然被后手拿出来线段222就必败了。那么我们可以枚举先手将线段444分成的两段的长度,如果两段中有一段是线段222或者线段444,那么肯定是不行的。那么只剩下线段111和线段333了,只需要判断以下线段333的个数即可。

// Problem: E. Game With String
// Contest: Codeforces - Educational Codeforces Round 73 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1221/problem/E
// Memory Limit: 256 MB
// Time Limit: 3000 ms
//
// Powered by CP Editor (https://cpeditor.org)//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
//#pragma GCC optimize(2)
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<cmath>
#include<cctype>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<sstream>
#include<ctime>
#include<cstdlib>
#include<random>
#include<cassert>
#define X first
#define Y second
#define L (u<<1)
#define R (u<<1|1)
#define pb push_back
#define mk make_pair
#define Mid ((tr[u].l+tr[u].r)>>1)
#define Len(u) (tr[u].r-tr[u].l+1)
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define db puts("---")
using namespace std;//void rd_cre() { freopen("d://dp//data.txt","w",stdout); srand(time(NULL)); }
//void rd_ac() { freopen("d://dp//data.txt","r",stdin); freopen("d://dp//AC.txt","w",stdout); }
//void rd_wa() { freopen("d://dp//data.txt","r",stdin); freopen("d://dp//WA.txt","w",stdout); }typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;const int N=1000010,mod=1e9+7,INF=0x3f3f3f3f;
const double eps=1e-6;int a,b,n;
char s[N];int get(int cnt) {if(cnt<b) return 1;else if(cnt<a) return 2;else if(cnt<2*b) return 3;else return 4;
}int main()
{//  ios::sync_with_stdio(false);
//  cin.tie(0);int _; scanf("%d",&_);while(_--) {int x,y,z; x=y=z=0;scanf("%d%d%s",&a,&b,s+1);n=strlen(s+1);int len=0;for(int i=1;i<=n;i++) {if(s[i]=='X') continue;int cnt=0;while(i<=n&&s[i]=='.') i++,cnt++; i--;if(cnt<b) continue;else if(cnt<a) x++;else if(cnt<2*b) y++;else z++,len=cnt;}if(x||z>1) puts("NO");else {if(!z) {if(y%2==0) puts("NO");else puts("YES");} else {bool flag=false;for(int st=0;st+a<=len;st++) {int l=st,r=len-st-a;int id1=get(l),id2=get(r);if(id1==2||id2==2||id1==4||id2==4) continue;int now=y+(id1==3)+(id2==3);if(now%2==0) {flag=true;break;}}if(flag) puts("YES");else puts("NO");}}}return 0;
}
/**/

Educational Codeforces Round 73 (Rated for Div. 2) E. Game With String 思维博弈 好题(2500)相关推荐

  1. Educational Codeforces Round 73 (Rated for Div. 2) F. Choose a Square 线段树 + 二维转一维

    传送门 文章目录 题意: 思路: 题意: 给你nnn个点(xi,yi)(x_i,y_i)(xi​,yi​),每个点有个价值cic_ici​,现在你可以框一个正方形,要求左下角和右上角的坐标(x,y)( ...

  2. Educational Codeforces Round 73 (Rated for Div. 2) Make The Fence Great Again dp + 结论

    传送门 文章目录 题意: 思路: 题意: 思路: 首先证明一个结论:一个数最多被加两次. 首先假设a[i]=a[i−1]a[i]=a[i-1]a[i]=a[i−1]或a[i]=a[i+1]a[i]=a ...

  3. Educational Codeforces Round 73 (Rated for Div. 2)

    A 很简单的一个模拟,只要前面的数字有两个以上就能合成后面的,我们进行一遍合成看能不能出现2048就可以了. #include<cstdio> #include<cstring> ...

  4. Educational Codeforces Round 50 (Rated for Div. 2)的A、B、C三题AC代码

    A题链接:https://codeforces.com/contest/1036/problem/A A题AC代码: 1 #include <stdio.h> 2 #include < ...

  5. Educational Codeforces Round 81 (Rated for Div. 2) C. Obtain The String 序列自动机

    传送门 文章目录 题意: 思路: 题意: 给你两个串s,ts,ts,t,每次可以取sss串的一个子序列,问你最少取多少次子序列,将这些子序列拼起来能得到ttt. 思路: 发现我题解里面没写过序列自动机 ...

  6. Educational Codeforces Round 101 (Rated for Div. 2) C. Building a Fence 思维取范围

    传送门 题意: 思路: 刚看到这个题其实是没什么思路,想过从前往后推或者从后往前推,但是都不是很可行.因为两边都有一个固定的挡板挡住,我们可以根据其中的一个算出来每个位置高度的范围,让后检查一下范围是 ...

  7. Educational Codeforces Round 96 (Rated for Div. 2) C. Numbers on Whiteboard///思维

    cf地址 题目大意:给一个数n,有1~n的数,每次现在两个数a,b,将这两个数去掉,然后添加一个(a+b)/2的数(向上取整),进行n-1次操作后,问你最后剩下的数最小是多少. 思路:最小的数必定为2 ...

  8. Educational Codeforces Round 101 (Rated for Div. 2) D. Ceil Divisions(思维)

    给出数 n ,数组 a 为 {1,2,3,--n},最多有 n+5 次机会,将任意两个不相等的数做  ceil(x/y) 运算,使得最后的数组 a 只有一个 2,其余全为 1,给出运算次数具体的运算步 ...

  9. Educational Codeforces Round 90 (Rated for Div. 2)(A, B, C, D, E)

    Educational Codeforces Round 90 (Rated for Div. 2) Donut Shops 思路 分三种情况: a==c/ba == c / ba==c/b这个时候两 ...

最新文章

  1. springcloud是什么_阿里P8道出,入职阿里必会199道SpringCloud面试题,你能掌握多少?...
  2. 在Linux server上建立NAS文件服务器
  3. bzoj 2435: [Noi2011]道路修建 树上 dp
  4. Golang之错误处理
  5. HTML5开发都能干什么?从事哪些岗位?
  6. SAP Spartacus CMS 页面加载逻辑和性能的优化
  7. PC软件开发技术之一:在WinCC中通过VBS操作SQL Server2005
  8. 城市轨道交通运营管理属于什么院系_专业介绍|城市轨道交通运营管理专业
  9. Java屏蔽输入法_技巧:如何禁止输入法切换到全角状态
  10. informantion_schema库介绍
  11. Flutter 常见问题总结
  12. Linux 下子线程 exit code 在主线程中的使用
  13. Kendo UI使用方法与教程
  14. 白话区块链 之 11 - 区块链的链 是什么?
  15. c语言星钻图形的输出
  16. 平行四边形(几何)题解
  17. scandef格式详细说明
  18. 剥opgw光缆工具_ADSS光缆开剥光缆常用方法及开剥注意点
  19. vscode自定义消息配置
  20. csdn头像怎么改不了解决方法

热门文章

  1. swift string转int_swift中结构体和类的区别(值类型和引用类型的区别)
  2. 跟你们讲一个鬼故事,TA回来了!
  3. 数学有多震撼?!我真的没有在开车!
  4. 有趣的灵魂,从高质量的阅读开始
  5. 下班忘打卡了什么后果_工厂园区安装人脸识别门禁系统有什么好处?
  6. axure 组件_技巧分享 | Axure后台组件制作的全过程
  7. python实例编程_python 编程实例 5
  8. win10前置耳机插孔没声音_音频服务未运行怎么办?win7和win10电脑没声音了恢复方法...
  9. matlab编程数字信号,MATLAB--数字信号实验.doc
  10. vst3插件_Steinberg发布新的VST 3.7 SDK,音乐软件开发者速来围观