atcoder#ARC097A. [ABC097C] K-th Substring
[ABC097C] K-th Substring
Score : points
Problem Statement
You are given a string . Among the different substrings of , print the -th lexicographically smallest one.
A substring of is a string obtained by taking out a non-empty contiguous part in .
For example, if ababc
, a
, bab
and ababc
are substrings of , while ac
, z
and an empty string are not.
Also, we say that substrings are different when they are different as strings.
Let and be two distinct strings. is lexicographically larger than if and only if is a prefix of or where is the smallest integer such that .
Constraints
- consists of lowercase English letters.
- has at least different substrings.
Partial Score
- points will be awarded as a partial score for passing the test set satisfying .
Input
Input is given from Standard Input in the following format:
Output
Print the -th lexicographically smallest substring of .
aba
4
b
has five substrings: a
, b
, ab
, ba
and aba
.
Among them, we should print the fourth smallest one, b
.
Note that we do not count a
twice.
atcoderandatcodeer
5
andat
z
1
z