传送门

注意到后手可以模仿先手的操作,那么如果一回合之内没法决定胜负则一定 $\text{once again!}$

考虑如何判断一回合内能否决定胜负

首先如果最左边和最右的 $0$ 或 $1$ 距离小于等于 $k$,那么先手显然赢

如果最左边和最右的 $0$ 和 $1$ 中间都差了大于等于 $k$ 个位置,那么考虑后手能不能赢

枚举一下先手第一步即可(代码因为比赛是写的,比较奇怪,我感觉也不用参考代码吧..)

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int read()
{
int x=,f=; char ch=getchar();
while(ch<''||ch>'') { if(ch=='-') f=-; ch=getchar(); }
while(ch>=''&&ch<='') { x=(x<<)+(x<<)+(ch^); ch=getchar(); }
return x*f;
}
const int N=2e5+;
int n,m;
char s[N];
int main()
{
n=read(),m=read();
scanf("%s",s+);
int l0=n+,r0=,l1=n+,r1=;
for(int i=;i<=n;i++)
{
if(s[i]=='') l0=min(l0,i),r0=max(r0,i);
else l1=min(l1,i),r1=max(r1,i);
}
if(r0-l0+<=m||r1-l1+<=m) { printf("tokitsukaze\n"); return ; }
int pre=;
for(int i=;i<=n;i++)
{
if(s[i]!=s[i-]) pre=i;
if(i-pre+>=m) { printf("once again\n"); return ; }
}
for(int i=;i+m-<=n;i++)
{
int l=i,r=i+m-;
if(l>l0&&r<r0) { printf("once again\n"); return ; }
if(l>l1&&r<r1) { printf("once again\n"); return ; }
}
printf("quailty\n");
return ;
}

Codeforces 1190C. Tokitsukaze and Duel的更多相关文章

  1. Codeforces 1190C Tokitsukaze and Duel game

    题意:有一个长为n的01串,两个人轮流操作,每个人可以把某个长度为m的区间变成相同颜色,谁在操作后整个串颜色相同就赢了.问最后是谁赢?(有可能平局) 思路:容易发现,如果第一个人不能一击必胜,那么他就 ...

  2. Codeforces - 1191E - Tokitsukaze and Duel - 博弈论 - 尺取

    https://codeforc.es/contest/1191/problem/E 参考自:http://www.mamicode.com/info-detail-2726030.html 和官方题 ...

  3. [Codeforces 1191D] Tokitsukaze, CSL and Stone Game(博弈论)

    [Codeforces 1191D] Tokitsukaze, CSL and Stone Game(博弈论) 题面 有n堆石子,两个人轮流取石子,一次只能从某堆里取一颗.如果某个人取的时候已经没有石 ...

  4. E - Tokitsukaze and Duel CodeForces - 1190C (博弈 + 窗体移动)

    "Duel!" Betting on the lovely princess Claris, the duel between Tokitsukaze and Quailty ha ...

  5. Codeforces Round #573 (Div. 2) E. Tokitsukaze and Duel (博弈)

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  6. Tokitsukaze and Duel CodeForces - 1191E (博弈论)

    大意: 给定01串, 两人轮流操作, Tokitsukaze先手. 每次操作可以选择长为$k$的区间, 全部替换为$0$或$1$, 若替换后同色则赢. 求最后结果. 先判断第一步是否能直接赢, 不能的 ...

  7. Codeforces - 1191F - Tokitsukaze and Strange Rectangle - 组合数学 - 扫描线

    https://codeforces.com/contest/1191/problem/F 看了一下题解的思路,感觉除了最后一段以外没什么启发. 首先离散化x加快速度,免得搞多一个log.其实y不需要 ...

  8. Codeforces - 1191C - Tokitsukaze and Discard Items - 模拟

    https://codeforces.com/contest/1191/problem/C 一开始想象了一下,既然每次删除都是往前面靠,那么好像就是页数*页容量+空位数=最多容纳到的坐标. 至于为什么 ...

  9. Codeforces - 1191B - Tokitsukaze and Mahjong - 模拟

    https://codeforces.com/contest/1191/problem/B 小心坎张听的情况. #include<bits/stdc++.h> using namespac ...

随机推荐

  1. 代码优化-多态代替IF条件判断

    场景描述 在开发的场景中,常常会遇到打折的业务需求,每个用户对应的等级,他们的打折情况也是不一样的.例如普通会员打9折,青铜会员打8.5折,黄金会员打8折等等.在一般开发中最简单的就是判断用户的等级, ...

  2. cha[] strrev(char[])

    反转字符串  保留在原函数中

  3. Java 实现 2的次幂表示

    问题描述 任何一个正整数都可以用2进制表示,例如:137的2进制表示为10001001. 将这种2进制表示写成2的次幂的和的形式,令次幂高的排在前面,可得到如下表达式:137=2^7+2^3+2^0 ...

  4. 去掉input type=file的默认样式

    原样式: 解决: 加style="opacity: 0;"变成透明的 然后可以外面套个div,在div上自定义样式.

  5. String,int,Integer之间的转换

    public class Test{ public static void main(String[] args) { //int转换成Integer Integer in = new Integer ...

  6. springboot备忘

    1.springboot中有ApplicationRunner类,如果项目中的启动类名称也是ApplicationRunner,单元测试时需要注意:import不要import到springboot的 ...

  7. storm备忘

    [命令]storm rebalance topology-name [-w wait-time-secs] [-n new-num-workers] [-e component=parallelism ...

  8. leetcode探索中级算法

    leetcode探索中级答案汇总: https://leetcode-cn.com/explore/interview/card/top-interview-questions-medium/ 1)数 ...

  9. 服务安全-IAM:百科

    ylbtech-服务安全-IAM:百科 IAM(身份识别与访问管理(简称大4A)) IAM(Identity and Access Management 的缩写),即“身份识别与访问管理”,具有单点登 ...

  10. dom4j工具对XML写入修改删除操作实现

    import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.io.SAXReader; import ...