[BOJ 16923] 다음 다양한 단어

View as PDF

Submit solution

Points: 2
Time limit: 2.0s
Memory limit: 512M

Problem types
Allowed languages
Assembly, Awk, C, C++, Java, Pascal, Perl, Python, Sed, Text

다양한 단어란 모두 다른 알파벳 소문자로만 이루어진 단어를 의미한다. 예를 들어, "codeplus", "coding", "algorithm"은 다양한 단어, "baekjoon", "startlink"는 다양한 단어가 아니다.</p>

다양한 단어 S가 주어졌을 때, 사전 순으로 S의 바로 다음에 오는 다양한 단어를 구해보자.

입력 형식

첫째 줄에 길이가 26보다 작거나 같은 다양한 단어 S가 주어진다.

출력 형식

사전 순으로 S의 바로 다음에 오는 다양한 단어를 출력한다. 바로 다음에 오는 단어가 없는 경우에는 -1을 출력한다.

예제 입력 1

codeplus

예제 출력 1

codeplusa

예제 입력 2

abc

예제 출력 2

abcd

예제 입력 3

zyxwvutsrqponmlkjihgfedcba

예제 출력 3

-1

예제 입력 4

abcdefghijklmnopqrstuvwzyx

예제 출력 4

abcdefghijklmnopqrstuvx

Comments

There are no comments at the moment.