CF979B.Treasure Hunt
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.
The three friends are very smart so they passed all the challenges very quickly and finally reached the destination. But the treasure can only belong to one cat so they started to think of something which can determine who is worthy of the treasure. Instantly, Kuro came up with some ribbons.
A random colorful ribbon is given to each of the cats. Each color of the ribbon can be represented as an uppercase or lowercase Latin letter. Let's call a consecutive subsequence of colors that appears in the ribbon a subribbon. The beauty of a ribbon is defined as the maximum number of times one of its subribbon appears in the ribbon. The more the subribbon appears, the more beautiful is the ribbon. For example, the ribbon aaaaaaa has the beauty of 7 because its subribbon a appears 7 times, and the ribbon abcdabc has the beauty of 2 because its subribbon abc appears twice.
The rules are simple. The game will have n turns. Every turn, each of the cats must change strictly one color (at one position) in his/her ribbon to an arbitrary color which is different from the unchanged one. For example, a ribbon aaab can be changed into acab in one turn. The one having the most beautiful ribbon after n turns wins the treasure.
Could you find out who is going to be the winner if they all play optimally?
大型生日派对结束后,Katie 仍希望 Shiro 能继续享受更多乐趣。随后,她想出了一个名为“寻宝”的游戏。当然,她邀请了她最好的朋友 Kuro 和 Shiro 一同参与。
这三位朋友都非常聪明,因此他们迅速通过了所有挑战,最终抵达了目的地。但宝藏只能归属一只猫,于是他们开始思考某种方法来决定谁才有资格获得宝藏。就在此时,Kuro 灵机一动,提出了彩带(ribbons)的主意。
每只猫被随机分发一条彩色彩带。彩带中每种颜色可用一个大写或小写的拉丁字母表示。我们将彩带中一段连续的颜色序列称为一个子彩带(subribbon)。一条彩带的“美丽值”(beauty)定义为:其所有子彩带在该彩带中出现次数的最大值。子彩带出现得越频繁,彩带就越美丽。例如,彩带 aaaaaaa 的美丽值为 7,因为其子彩带 a 出现了 7 次;而彩带 abcdabc 的美丽值为 2,因为其子彩带 abc 出现了 2 次。
游戏规则很简单:共进行 n 轮。每轮中,每只猫必须严格地将自己彩带中某一个位置的颜色更改为任意一种不同于原色的新颜色(即每次恰好修改一个字符,且新字符不能与原字符相同)。例如,彩带 aaab 可在一轮内变为 acab。经过 n 轮后,拥有最美丽彩带的猫赢得宝藏。
如果三只猫均以最优策略进行游戏,你能判断出最终的获胜者是谁吗?
输入格式
The first line contains an integer n (0≤n≤109) — the number of turns.
Next 3 lines contain 3 ribbons of Kuro, Shiro and Katie one per line, respectively. Each ribbon is a string which contains no more than 105 uppercase and lowercase Latin letters and is not empty. It is guaranteed that the length of all ribbons are equal for the purpose of fairness. Note that uppercase and lowercase letters are considered different colors.
第一行包含一个整数 n(0≤n≤109)—— 表示回合数。
接下来的三行每行分别给出 Kuro、Shiro 和 Katie 的彩带,共三条。每条彩带是一个字符串,仅包含至多 105 个大小写拉丁字母,且非空。为保证公平性,保证所有彩带长度相等。注意:大小写字母被视为不同的颜色。
输出格式
Print the name of the winner ("Kuro", "Shiro" or "Katie"). If there are at least two cats that share the maximum beauty, print "Draw".
输出获胜者的名字(“Kuro”、“Shiro” 或 “Katie”)。如果至少有两只猫具有相同的最大美丽值,则输出 “Draw”。
输入输出样例
输入#1
3 Kuroo Shiro Katie
输出#1
Kuro
输入#2
7 treasurehunt threefriends hiCodeforces
输出#2
Shiro
输入#3
1 abcabc cbabac ababca
输出#3
Katie
输入#4
15 foPaErcvJ mZaxowpbt mkuOlaHRE
输出#4
Draw
说明/提示
In the first example, after 3 turns, Kuro can change his ribbon into ooooo, which has the beauty of 5, while reaching such beauty for Shiro and Katie is impossible (both Shiro and Katie can reach the beauty of at most 4, for example by changing Shiro's ribbon into SSiSS and changing Katie's ribbon into Kaaaa). Therefore, the winner is Kuro.
In the fourth example, since the length of each of the string is 9 and the number of turn is 15, everyone can change their ribbons in some way to reach the maximal beauty of 9 by changing their strings into zzzzzzzzz after 9 turns, and repeatedly change their strings into azzzzzzzz and then into zzzzzzzzz thrice. Therefore, the game ends in a draw.
在第一个例子中,经过 3 轮操作后,Kuro 可将其丝带变为 ooooo,其美观度为 5;而 Shiro 和 Katie 均无法达到该美观度(Shiro 和 Katie 最多只能达到美观度 4,例如 Shiro 可将其丝带变为 SSiSS,Katie 可将其丝带变为 Kaaaa)。因此,获胜者是 Kuro。
在第四个例子中,由于每个字符串的长度均为 9,且操作轮数为 15,因此三人均可通过某种方式将其丝带变为美观度最大的 9:先用 9 轮将各自字符串变为 zzzzzzzzz,再反复执行“变为 azzzzzzzz,再变为 zzzzzzzzz”这一过程三次。因此,游戏以平局结束。
输入解题思路,AI测评打分。不知道怎么写?