CodeForces A. Letters Cyclic Shift【字符串】

来源:互联网 发布:香港好玩吗 知乎 编辑:程序博客网 时间:2024/04/27 20:02
A. Letters Cyclic Shift
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z 'y 'x 'b 'a 'z'. In other words, each character is replaced with the previous character of English alphabet and 'a' is replaced with 'z'.

What is the lexicographically minimum string that can be obtained from s by performing this shift exactly once?

Input

The only line of the input contains the string s (1 ≤ |s| ≤ 100 000) consisting of lowercase English letters.

Output

Print the lexicographically minimum string that can be obtained from s by shifting letters of exactly one non-empty substring.

Examples
input
codeforces
output
bncdenqbdr
input
abacaba
output
aaacaba
Note

String s is lexicographically smaller than some other string t of the same length if there exists some 1 ≤ i ≤ |s|, such thats1 = t1, s2 = t2, ..., si - 1 = ti - 1, and si < ti.

刚做这首题的时候,宝宝也是很无语,一堆英文看不懂也就算了。。给的数据也让我分析不出来。。最后好不容易搞懂了,用JAVA写了一遍,超时,用C写,超时,最后用C++才给过了。。百度的时候发现了一个神奇的头文件#include<bits/stdc++.h>,据说包含了C++里的所有头文件,长姿势了,,,
code:
#include<bits/stdc++.h>using namespace std;int main() {string str;int i,j;cin>>str;for(i=0;i<str.size();i++){if(str[i]!='a'){break;}}for(j=i;j<str.size();j++){if(str[j]=='a'){break;}str[j]--;}if(i==str.size()){str[str.size()-1]='z';}cout<<str<<endl;return 0;}


0 0
原创粉丝点击