Absent
Ограничения: время – 1s/2s, память – 64MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод
Послать решение Blockly Посылки Темы Где Обсудить (0)
Given a string of symbols, it's natural to look it over and see what substrings are present. In
this problem, you are given a string and asked to consider what substrings are absent. Of course,
a given string has finite length and therefore only finitely many substrings, so there are always
infinitely many strings that don't appear as substrings of a given string. We'll seek to find the
lexicographically least string that is absent from the given string.
Input Format
Each line of input contains a string `x` over the alphabet `{a,\ b,\ c}`. `x` may be the empty string,
as shown in the second line of the input sample below, or a nonempty string. Length of string is not more 200 characters.
Output Format
For each input string `x`, find and output the lexicographically least string s over the alphabet
`{a,\ b,\ c}` such that `s` is not a substring of `x`; i.e. `s` is absent from `x`. Since the empty string is a
substring of every string, your output `s` is necessarily nonempty. Recall that a string is lexicographically
less than another string if it is shorter or is the same length and alphabetically less;
e.g. "b"<"aa", "abc"<"acb". Format each line of output
to show `s` and `x`, as shown in the output sample below.
Sample Input
bcabacbaa
aaabacbbcacc
Sample Output
bb is absent from bcabacbaa
a is absent from
aac is absent from aaabacbbcacc
Source: California State Polytechnic University Programming Contest, Spring 2009