[BOJ 8114] Palindromes
View as PDFA word is a palindrome if and only if it remains the same when read backwards. A palindrome is even if it has an even positive number of letters.</p>
The word abaaba is an example of an even palindrome.
An even palindrome decomposition of a word is its division into separate parts, every one of which is an even palindrome.
For the word:
bbaabbaabbbaaaaaaaaaaaabbbaa
the following are even palindrome decompositions:
bbaabb aabbbaaaaaaaaaaaabbbaa
and
bb aa bb aa bb baaaaaaaaaaaab bb aa
The first decomposition consists of the least possible number of even palindromes, and the second one is a decomposition having the maximal possible number of even palindromes.
Notice that a word might have many different even palindrome decompositions or might have no such a decomposition.
Write a program which:
- reads a word from the standard input and examines whether it can be decomposed into even palindromes,
- if not, then the program writes to the standard output only one word
NIE("no"), - if the word can be decomposed, then the program writes the decompositions of the word into the minimal and maximal number of even palindromes.
The standard input contains one word consisting of at least 1 and at most 200 small letters of English alphabet. The word is written in one line with no spaces between letters.
We assume that the given word is written correctly in the standard input, and your program need not verify that.
출력 형식
The standard output should contain:
- only one word
NIE
</ul>
- in the first line - a sequence of words separated by spaces, forming a decomposition of the given word into the minimal number of even palindromes
- in the second line - a decomposition of the given word into the maximal number of even palindromes
or
예제 입력 1
bbaabbaabbbaaaaaaaaaaaabbbaa
예제 출력 1
bbaabb aabbbaaaaaaaaaaaabbbaa
bb aa bb aa bb baaaaaaaaaaaab bb aa
예제 입력 2
abcd
예제 출력 2
NIE
예제 입력 3
abaaba
예제 출력 3
abaaba
abaaba
Comments