#K70572. Unique Palindromic Substrings

    ID: 33338 Type: Default 1000ms 256MiB

Unique Palindromic Substrings

Unique Palindromic Substrings

Given a string S and two integers minLength and maxLength, find all unique substrings of S that are palindromes and whose lengths lie in the interval ( [minLength, maxLength] ) (inclusive). A palindrome is a string that reads the same backward as forward. The output must list these palindromic substrings in lexicographically sorted order (ascending), each on its own line. If no such substring exists, output nothing.

Input Format: The first line contains the string S. The second line contains two space-separated integers representing minLength and maxLength.

Output Format: Output the unique palindromic substrings (if any) that meet the given criteria. Each substring should be printed on its own line in lexicographical order.

inputFormat

The input is read from standard input (stdin). The first line contains a non-empty string S consisting of lowercase letters. The second line contains two integers minLength and maxLength separated by a space. It is guaranteed that minLength and maxLength are non-negative integers.

outputFormat

The output should be written to standard output (stdout). Print all unique palindromic substrings of S that have a length between minLength and maxLength (inclusive), sorted in lexicographical order. Each substring should be printed on a separate line. If there are no valid palindromic substrings, output nothing.## sample

aabaa
1 2
a

aa b

</p>