Subtle Substring Subtraction Solution | Codeforces Problem Solution 2022
Alice and Bob are playing a game with strings. There will be rounds in the game. In each round, there will be a string 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 .
More formally, if there was a string the player can choose a substring with length of corresponding parity and remove it. After that the string will become .
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 is , the value of is , the value of is , , and the value of is . 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 () denoting the number of rounds.
Each of the next lines contain a single string () consisting of lowercase English letters, denoting the string used for the round. Here denotes the length of the string .
It is guaranteed that the sum of over all rounds does not exceed .
No comments:
Post a Comment