Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
Though both Rikka and Yuta are busy with study, on their common leisure, they always spend time with each other and sometimes play some interesting games.
Today, the rule of the game is quite simple. Given a string s with only lowercase letters. Rikka and Yuta need to operate the string in turns while the first operation is taken by Rikka.
In each turn, the player has two choices: The first one is to terminate the game, and the second one is to select an index i of s and right shift the value of char si, i.e., a→b,b→c,…,y→z,z→a.
If the game is still alive after 2101 turns, i.e., after Yuta finishes his 2100 turns, the game will end automatically. The final result is the value of s when the game is over.
Now, Rikka wants to minimize the lexicographical order of the result while Yuta wants to maximize it. You are required to calculate the result of the game if both Rikka and Yuta play optimally.
For two string a and b with equal length m, a is lexicographically smaller than b if and only if there exists an index i∈[1,n] which satisfies ai
The first line of the input contains an integer T(1≤T≤100), the number of test cases.
For each test case, the input contains a single line with a single string with only lowercase letters, the initial value of s(1≤|s|≤100).
For each test case, output a single line with a single string, the answer.
2
a zbc
a
bbc
最近特别水逆,上午请假去取票,花了一上午时间,整个人都不好了,现在也没状态写题,一个签到也能写这么久。
代码很简短,核心代码可能只有三行,可是我一直都在wa。。。
开始认为只要第一个是z变成b就行了,然后后来才发现yz这种情况输出的是yb,也就是z前面是y或者前面一直是y时z要变成b。然后还是wa。。。
然后发现了ayz这种情况我会输出ayb,也就是我写的方式有问题,最后改成了下面的代码。
#include
using namespace std;
#define ll long long
const int MAXN = 1e5 + 7;
int main()
{
ios::sync_with_stdio(0);
int t;
cin>>t;
string s;
while(t--)
{
cin>>s;
for(int i = 0; i < s.size(); i++)
{
if(s[i] == 'y') continue;
if(s[i] == 'z') s[i] = 'b', break;
else break;
}
cout<