2199.Letters Cyclic Shift

Time Limit: 1s Memory Limit: 256MB

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' 2199_1.png 'y' 2199_1.png 'x' 2199_2.png 'b' 2199_1.png 'a' 2199_1.png '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 Format(From the terminal/stdin)

Input The only line of the input contains the string s (1 \le |s| \le 100000) consisting of lowercase English letters.

Output Format(To the terminal/stdout)

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

Sample Input 1

Copy
codeforces
          \n

Sample Output 1

Copy
bncdenqbdr
          \n

Sample Input 2

Copy
abacaba
       \n

Sample Output 2

Copy
aaacaba
       \n

Hints

String s is lexicographically smaller than some other string t of the same length if there exists some 1 \le i \le |s|, such that s1=t1,s2=t2,...,si-1=ti-1, and si \lt ti.

Submit

请先 登录

© 2025 FAQs