Tokitsukaze and Duel
题意翻译
题意:
给你一个长度为n的01字符串,和一个整数k。二人进行做博弈游戏,每个人必须选择一个连续的k个字符,把这连续的k个字符全变为0或者1
如果某次操作之后整个字符串全为1或者0,那么这个胜利,如果有无限多步要走,那么算平局,假设二人都绝顶聪明。给你初始局面,问游戏结果是什么?
题目描述
"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.
输入输出格式
输入格式
The first line contains two integers $ n $ and $ k $ ( $ 1 \le k \le n \le 10^5 $ ).
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 $ .
输出格式
Print "once again" (without quotes) if the total number of their moves can exceed $ 10^9 $ , 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.
输入输出样例
输入样例 #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.