Codeforces 1190C. Tokitsukaze and Duel
注意到后手可以模仿先手的操作,那么如果一回合之内没法决定胜负则一定 $\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的更多相关文章
- Codeforces 1190C Tokitsukaze and Duel game
题意:有一个长为n的01串,两个人轮流操作,每个人可以把某个长度为m的区间变成相同颜色,谁在操作后整个串颜色相同就赢了.问最后是谁赢?(有可能平局) 思路:容易发现,如果第一个人不能一击必胜,那么他就 ...
- Codeforces - 1191E - Tokitsukaze and Duel - 博弈论 - 尺取
https://codeforc.es/contest/1191/problem/E 参考自:http://www.mamicode.com/info-detail-2726030.html 和官方题 ...
- [Codeforces 1191D] Tokitsukaze, CSL and Stone Game(博弈论)
[Codeforces 1191D] Tokitsukaze, CSL and Stone Game(博弈论) 题面 有n堆石子,两个人轮流取石子,一次只能从某堆里取一颗.如果某个人取的时候已经没有石 ...
- E - Tokitsukaze and Duel CodeForces - 1190C (博弈 + 窗体移动)
"Duel!" Betting on the lovely princess Claris, the duel between Tokitsukaze and Quailty ha ...
- Codeforces Round #573 (Div. 2) E. Tokitsukaze and Duel (博弈)
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- Tokitsukaze and Duel CodeForces - 1191E (博弈论)
大意: 给定01串, 两人轮流操作, Tokitsukaze先手. 每次操作可以选择长为$k$的区间, 全部替换为$0$或$1$, 若替换后同色则赢. 求最后结果. 先判断第一步是否能直接赢, 不能的 ...
- Codeforces - 1191F - Tokitsukaze and Strange Rectangle - 组合数学 - 扫描线
https://codeforces.com/contest/1191/problem/F 看了一下题解的思路,感觉除了最后一段以外没什么启发. 首先离散化x加快速度,免得搞多一个log.其实y不需要 ...
- Codeforces - 1191C - Tokitsukaze and Discard Items - 模拟
https://codeforces.com/contest/1191/problem/C 一开始想象了一下,既然每次删除都是往前面靠,那么好像就是页数*页容量+空位数=最多容纳到的坐标. 至于为什么 ...
- Codeforces - 1191B - Tokitsukaze and Mahjong - 模拟
https://codeforces.com/contest/1191/problem/B 小心坎张听的情况. #include<bits/stdc++.h> using namespac ...
随机推荐
- python-matplotlib-2
figure的使用 x = np.linspace(-1, 1, 50) y1 = 2 * x + 1 #figure 1 plt.figure() plt.plot(x, y1) # figure ...
- Hive使用与安装步骤
1.Hive安装与配置 Hive官网:https://hive.apache.org/ 1. 安装文件下载 从Apache官网下载安装文件 http://mirror.bit.edu.cn/apach ...
- [题解] [SDOI2010] 古代猪文
题面 题解 题目所求即为 \[ G ^ {\sum_{d | n}C_{n}^{d}} \bmod {999911659} \] 考虑到有这样一个式子 \[ a ^ b \equiv a ^ {b \ ...
- Hadoop-2.7.5完全分布式搭建
1.在虚拟机上安装Hadoop完全分布式准备工作 1)这里使用的是VMWare软件,在VMWare上安装一个CentOS6.5,并再克隆两个机器配置相关MAC地址,以及配置机器名 2)三台虚拟机配置好 ...
- 20175215 2018-2019-2 第十周java课程学习总结
第十二章 Java多线程机制 12.1 进程与线程 12.1.1 操作系统与进程 程序是一段静态的代码,它是应用软件执行的蓝本. 进程是程序的一次动态执行过程,它对应了从代码加载.执行至执行完毕的一个 ...
- SRS之接收推流线程:recv
SrsPublishRecvThread.SrsRecvThread.SrsReusableThread2.SrsThread 之间的关系图 1. recv 线程函数:SrsThread::threa ...
- While 循环 kotlin(11)
While 循环while 和 do .. while 照常使用 while (x > 0) { x--} do { val y = retrieveData()} while (y != nu ...
- JAVA向C传递数据
传递数组 数组是个对象,传递对象就是传递地址,修改地址上的值,数组的内容就会改变 //获取数组首地址 int* p = (*env)->GetIntArrayElements(env, arra ...
- 数据中心网络架构的问题与演进 — Overlay 网络
目录 文章目录 目录 前文列表 数据中心网络架构演进回顾 Overlay 网络 Overlay 网络的优势 基于 VxLAN Overlay 的 Spine-Leaf 网络架构 参考文章 前文列表 & ...
- 小D课堂 - 新版本微服务springcloud+Docker教程_3-02CAP理论知识
笔记 2.分布式应用知识CAP理论知识 简介:讲解分布式核心知识CAP理论 CAP定理: 指的是在一个分布式系统中,Consistency(一致性). Availabi ...