CF1190C.Tokitsukaze and Duel
提高+/省选-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
"Duel!"
Betting on the lovely princess Claris, the duel between Tokitsukaze and Quailty has started.
There are n cards in a row. Each card has two sides, one of which has color. At first, some of these cards are with color sides facing up and others are with color sides facing down. Then they take turns flipping cards, in which Tokitsukaze moves first. In each move, one should choose exactly k consecutive cards and flip them to the same side, which means to make their color sides all face up or all face down. If all the color sides of these n cards face the same direction after one's move, the one who takes this move will win.
Princess Claris wants to know who will win the game if Tokitsukaze and Quailty are so clever that they won't make mistakes.
“决斗!”
为可爱的公主克拉丽丝(Claris)下注,时雨(Tokitsukaze)与鹌鹑(Quailty)之间的决斗已经拉开帷幕。
一行中有 n 张卡片。每张卡片有两面,其中一面带有颜色。初始时,部分卡片的彩色面朝上,其余卡片的彩色面朝下。随后两人轮流翻转卡片,时雨先手。每次操作中,玩家必须恰好选择 k 张连续的卡片,并将它们全部翻转为同一面朝上,即让这 k 张卡片的彩色面全部朝上,或全部朝下。若某位玩家完成操作后,这 n 张卡片的彩色面全部朝向同一方向(即全朝上或全朝下),则该玩家获胜。
公主克拉丽丝想知道:如果时雨与鹌鹑都足够聪明、绝不失误,那么谁将赢得这场游戏?
输入格式
The first line contains two integers n and k (1≤k≤n≤105).
The second line contains a single string of length n that only consists of 0 and 1, representing the situation of these n cards, where the color side of the i-th card faces up if the i-th character is 1, or otherwise, it faces down and the i-th character is 0.
第一行包含两个整数 n 和 k(1≤k≤n≤105)。
第二行包含一个长度为 n 的字符串,该字符串仅由字符 0 和 1 组成,表示这 n 张卡片的状态:若第 i 个字符为 1,则第 i 张卡片的彩色面朝上;否则(即第 i 个字符为 0),其彩色面朝下。
输出格式
Print "once again" (without quotes) if the total number of their moves can exceed 109, which is considered a draw.
In other cases, print "tokitsukaze" (without quotes) if Tokitsukaze will win, or "quailty" (without quotes) if Quailty will win.
Note that the output characters are case-sensitive, and any wrong spelling would be rejected.
如果他们的总步数可以超过 109(视为平局),则输出 "once again"(不带引号)。
其他情况下,若 Tokitsukaze 将获胜,则输出 "tokitsukaze"(不带引号);若 Quailty 将获胜,则输出 "quailty"(不带引号)。
注意:输出的字符区分大小写,任何拼写错误都会被拒绝。
输入输出样例
输入#1
4 2 0101
输出#1
quailty
输入#2
6 1 010101
输出#2
once again
输入#3
6 5 010101
输出#3
tokitsukaze
输入#4
4 1 0011
输出#4
once again
说明/提示
In the first example, no matter how Tokitsukaze moves, there would be three cards with color sides facing the same direction after her move, and Quailty can flip the last card to this direction and win.
In the second example, no matter how Tokitsukaze moves, Quailty can choose the same card and flip back to the initial situation, which can allow the game to end in a draw.
In the third example, Tokitsukaze can win by flipping the leftmost five cards up or flipping the rightmost five cards down.
The fourth example can be explained in the same way as the second example does.
在第一个例子中,无论 Tokitsukaze 如何操作,她的操作后总会出现三张卡片的颜色面朝向相同方向,此时 Quailty 可翻转最后一张卡片使其朝向该方向并获胜。
在第二个例子中,无论 Tokitsukaze 如何操作,Quailty 均可选择同一张卡片将其翻回初始状态,从而使游戏以平局结束。
在第三个例子中,Tokitsukaze 可通过将最左侧的五张卡片向上翻转,或最右侧的五张卡片向下翻转来获胜。
第四个例子的分析方式与第二个例子相同。
输入解题思路,AI测评打分。不知道怎么写?