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 ...
随机推荐
- HDU 5115 Dire Wolf ——(区间DP)
比赛的时候以为很难,其实就是一个区间DP= =..思路见:点我. 区间DP一定要记住先枚举区间长度啊= =~!因为区间dp都是由短的区间更新长的区间的,所以先把短的区间更新完.. 代码如下: #inc ...
- postgresql-基础-1
概述 层状关系 网状关系 关系型数据库 关系型数据库 元祖:代表一行 属性:代表一列 主码:唯一确定一个元组的属性组,即主键 域:属性的取值范围 分量:元组中的一个属性值,即某一行 ...
- 库&插件&框架&工具
nodejs 入门 nodejs 入门教程,大家可以在 github 上提交错误 2016 年最好用的表单验证库 SMValidator.js 前端表单验证工具分享 浅谈前端线上部署与运维 说到前端部 ...
- SpringBoot2.X 静态文件配置
Spring Boot 默认会挨个从 META/resources > resources > static > public 里面找是否存在相应的资源,如果有则直接返回. 默认配置 ...
- TensorFlow 学习(1)——第一个程序:线性回归
目前这个程序还有很多地方没有搞懂,先跑一跑例程看看效果如何.从结果来看,最终的训练成果能够接近于预设的数据
- LC 272. Closest Binary Search Tree Value II 【lock,hard】
Given a non-empty binary search tree and a target value, find k values in the BST that are closest t ...
- Pytorch-创建tensor
引言 本篇介绍创建tensor的几种方式 Import from numpy from_numpy() float64 是 double 类型,也就是说从numpy导入的float其实是double类 ...
- golang(09) golang 接口内部实现
原文链接 http://www.limerence2017.com/2019/09/24/golang14/#more 前文介绍过golang interface用法,本文详细剖析interface内 ...
- C#通过Oracle.ManagedDataAccess无法访问Oralce (转)
原文转自:https://www.cnblogs.com/duanjt/p/6955173.html 问题描述:通过C#引用Oracle.ManagedDataAccess.dll访问Oracle,写 ...
- JavaScript基础入门07
目录 JavaScript 基础入门07 BOM window对象 Navigator对象 Screen 对象 Location对象 History 对象 JavaScript 基础入门07 BOM ...