#C4805. Find Palindromic Substrings
Find Palindromic Substrings
Find Palindromic Substrings
Given a string s, your task is to find all distinct palindromic substrings contained in it. A palindromic substring is a substring which reads the same backward as forward. The output should list these substrings sorted in ascending lexicographical order.
For example, if s = "abaaa"
, the palindromic substrings are a, aa, aaa, aba, b
.
The program should read from standard input (stdin
) and write the result to standard output (stdout
). The palindromic substrings must be printed on one line and separated by a single space.
inputFormat
The input consists of a single line containing a non-empty string s
.
outputFormat
Output the distinct palindromic substrings in ascending lexicographical order, separated by a space on a single line.
## sampleabaaa
a aa aaa aba b