CF1673A.Subtle Substring Subtraction
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Alice and Bob are playing a game with strings. There will be t rounds in the game. In each round, there will be a string s consisting of lowercase English letters.
Alice moves first and both the players take alternate turns. Alice is allowed to remove any substring of even length (possibly empty) and Bob is allowed to remove any substring of odd length from s .
More formally, if there was a string s=s1s2…sk the player can choose a substring slsl+1…sr−1sr with length of corresponding parity and remove it. After that the string will become s=s1…sl−1sr+1…sk .
After the string becomes empty, the round ends and each player calculates his/her score for this round. The score of a player is the sum of values of all characters removed by him/her. The value of a is 1 , the value of b is 2 , the value of c is 3 , … , and the value of z is 26 . The player with higher score wins the round. For each round, determine the winner and the difference between winner's and loser's scores. Assume that both players play optimally to maximize their score. It can be proved that a draw is impossible.
输入格式
The first line of input contains a single integer t ( 1≤t≤5⋅104 ) denoting the number of rounds.
Each of the next t lines contain a single string s ( 1≤∣s∣≤2⋅105 ) consisting of lowercase English letters, denoting the string used for the round. Here ∣s∣ denotes the length of the string s .
It is guaranteed that the sum of ∣s∣ over all rounds does not exceed 2⋅105 .
输出格式
For each round, print a single line containing a string and an integer. If Alice wins the round, the string must be "Alice". If Bob wins the round, the string must be "Bob". The integer must be the difference between their scores assuming both players play optimally.
输入输出样例
输入#1
5 aba abc cba n codeforces
输出#1
Alice 2 Alice 4 Alice 4 Bob 14 Alice 93
说明/提示
For the first round, "aba"Alice"aba""a"Bob"a""" . Alice's total score is 1+2=3 . Bob's total score is 1 .
For the second round, "abc"Alice"abc""a"Bob"a""" . Alice's total score is 2+3=5 . Bob's total score is 1 .
For the third round, "cba"Alice"cba""a"Bob"a""" . Alice's total score is 3+2=5 . Bob's total score is 1 .
For the fourth round, "n"Alice"n""n"Bob"n""" . Alice's total score is 0 . Bob's total score is 14 .
For the fifth round, "codeforces"Alice"codeforces""" . Alice's total score is 3+15+4+5+6+15+18+3+5+19=93 . Bob's total score is 0 .