CF1480A.Yet Another String Game
入门
通过率:0%
时间限制:2.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Homer has two friends Alice and Bob. Both of them are string fans.
One day, Alice and Bob decide to play a game on a string s=s1s2…sn of length n consisting of lowercase English letters. They move in turns alternatively and Alice makes the first move.
In a move, a player must choose an index i (1≤i≤n) that has not been chosen before, and change si to any other lowercase English letter c that c=si.
When all indices have been chosen, the game ends.
The goal of Alice is to make the final string lexicographically as small as possible, while the goal of Bob is to make the final string lexicographically as large as possible. Both of them are game experts, so they always play games optimally. Homer is not a game expert, so he wonders what the final string will be.
A string a is lexicographically smaller than a string b if and only if one of the following holds:
- a is a prefix of b, but a=b;
- in the first position where a and b differ, the string a has a letter that appears earlier in the alphabet than the corresponding letter in b.
荷马有两个朋友爱丽丝(Alice)和鲍勃(Bob),他们都是字符串爱好者。
一天,爱丽丝和鲍勃决定在长度为 n 的字符串 s=s1s2…sn(由小写英文字母组成)上玩一个游戏。他们轮流进行操作,爱丽丝先手。
每次操作中,玩家必须选择一个之前未被选过的下标 i(1≤i≤n),并将 si 修改为任意一个小写英文字母 c,满足 c=si。
当所有下标均已被选择后,游戏结束。
爱丽丝的目标是使最终字符串的字典序尽可能小,而鲍勃的目标是使最终字符串的字典序尽可能大。两人都精通博弈,因此总会采取最优策略。荷马并不精通博弈,因此他想知道最终的字符串会是什么。
字符串 a 的字典序小于字符串 b,当且仅当满足以下任一条件:
- a 是 b 的真前缀(即 a 是 b 的前缀,但 a=b);
- 在 a 与 b 首次出现不同字符的位置上,a 中该位置的字母在字母表中早于 b 中对应位置的字母。
输入格式
Each test contains multiple test cases. The first line contains t (1≤t≤1000) — the number of test cases. Description of the test cases follows.
The only line of each test case contains a single string s (1≤∣s∣≤50) consisting of lowercase English letters.
每个测试包含多个测试用例。第一行包含 t(1≤t≤1000)—— 测试用例的数量。随后是各测试用例的描述。
每个测试用例仅有一行,包含一个字符串 s(1≤∣s∣≤50),由小写英文字母组成。
输出格式
For each test case, print the final string in a single line.
对于每个测试用例,在一行中输出最终字符串。
输入输出样例
输入#1
3 a bbbb az
输出#1
b azaz by
说明/提示
In the first test case: Alice makes the first move and must change the only letter to a different one, so she changes it to 'b'.
In the second test case: Alice changes the first letter to 'a', then Bob changes the second letter to 'z', Alice changes the third letter to 'a' and then Bob changes the fourth letter to 'z'.
In the third test case: Alice changes the first letter to 'b', and then Bob changes the second letter to 'y'.
在第一个测试用例中:Alice 进行第一步操作,必须将唯一的字母更改为另一个不同的字母,因此她将其更改为 'b'。
在第二个测试用例中:Alice 将第一个字母更改为 'a',然后 Bob 将第二个字母更改为 'z',Alice 将第三个字母更改为 'a',接着 Bob 将第四个字母更改为 'z'。
在第三个测试用例中:Alice 将第一个字母更改为 'b',然后 Bob 将第二个字母更改为 'y'。
输入解题思路,AI测评打分。不知道怎么写?