Unique Substrings
Time limit1sMemory limit256 MB
Build a lowercase string of length at most 4096 that has exactly K distinct substrings, where K is at most 2^22.
- Level
Medium6 of 10
- Topics
- String, Greedy, Implementation
- Solved
- No attempts yet
Problem
Create a string of lowercase letters, where . The string must have exactly distinct substrings.
A substring is a sequence of the form for some . Two substrings are the same if they are the same sequence of letters.
Input
The first line contains one integer (). is not given. The string you create may have any length with .
Output
Print one line containing one string of lowercase letters, where . The string must have exactly distinct substrings. If several strings qualify, any of them is accepted. Under these constraints, such a string always exists.
Hint
For the first example, the 15 distinct substrings of banana are a, an, ana, anan, anana, b, ba, ban, bana, banan, banana, n, na, nan, and nana. Another string with 15 distinct substrings is aaaaaaaaaaaaaaa, which is also a correct output for the first example.