P23179 [AtCoder] [ABC007B] Dictionary Order
入门
题目描述

Problem Description

You are given a string $ A $. Output any string that is smaller than $ A $ in dictionary order using only lowercase alphabets (a-z). The string must be between 1 and 100 characters long. If no such string exists, output "-1".

For two strings $ S=S_1S_2...S_n $ and $ T=T_1T_2...T_m $, $ S < T $ in dictionary order if either of the following conditions is met:

  • There exists an integer $i\ (1≦i≦{\rm\ min}(n,m))$ such that for any integer $ j $ satisfying $ 1≦j≦i−1 $, $ S_j=T_j $ holds, and $ S_i < T_i $ holds.
  • For any integer $i\ (1≦i≦{\rm\ min}(n,m))$, $ S_i=T_i $ holds, and $ |S| < |T| $. Here, $ |X| $ denotes the length of string $ X $.

In simpler terms:

  • Compare each character of the strings from the beginning. The first mismatch determines the order. For example, comparing "abcd" and "ax" results in "abcd" being greater because 'b' > 'a' at the second character.
  • If one string runs out of characters during comparison, the shorter string is considered smaller. For example, "ab" is smaller than "abc".

Input Format

The input is given from the standard input in the following format:

$ A $

  • The first line contains the string $A\ (1 ≦ |A| ≦ 11)$. $ |A| $ denotes the length of string $ A $. $ A $ consists of only lowercase alphabets (a-z).

Output Format

Output a string that is smaller than $ A $ in dictionary order. The string must consist of only lowercase alphabets (a-z) and be between 1 and 100 characters long. If multiple solutions exist, any one of them is acceptable. If no such string exists, output "-1". End the output with a newline.

Sample Input and Output

Sample Input #1

xyz

Sample Output #1

xy

Sample Input #2

c

Sample Output #2

b

Sample Input #3

a

Sample Output #3

-1

Sample Input #4

aaaaa

Sample Output #4

aaaa

Notes/Hints

Sample Explanation 1

Of course, besides "xy", outputs like "abcd" would also be considered correct.

Sample Explanation 2

Either "a" or "b" would be considered a correct answer.

Sample Explanation 3

No string smaller than "a" exists. Note that the output string must be at least 1 character long, so an empty string is not acceptable.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
xyz
样例输出
xy