#K49957. Palindromic Substrings

    ID: 28757 Type: Default 1000ms 256MiB

Palindromic Substrings

Palindromic Substrings

Given a string \( s \), your task is to find and output all palindromic substrings of \( s \). A palindrome is a string that reads the same forwards and backwards. Note that duplicates are allowed; if the same palindromic substring occurs more than once, it should be output each time it is found.

The method to generate palindromic substrings is by expanding around each character (and between characters) in the string. The order of output should be the same as the discovery order using this center expansion approach.

For example, given the string "aab", possible palindromic substrings are:

a
aa
a
b

inputFormat

The input consists of a single line containing the string \( s \). The string may be empty or contain any visible characters.

outputFormat

Output all the palindromic substrings found in \( s \), each printed on a separate line, in the order they are discovered using the center expansion technique.

## sample
aab
a

aa a b

</p>