II Olympiad in Informatics 1994/1995
Author: Wojciech Rytter
|I stage contest|
A 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.
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.
bbaabbaabbbaaaaaaaaaaaabbbaathe following are even palindrome decompositions:
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.
We assume that the given word is written correctly in the file PAL.IN, and your program need not verify that.
bbaabbaabbbaaaaaaaaaaaabbbaayour program should create the following file PAL.OUT:
bbaabb aabbbaaaaaaaaaaaabbbaa bb aa bb aa bb baaaaaaaaaaaab bb aaFor the file PAL.IN:
abcdyour program should create the file PAL.OUT:
NIEFor the file PAL.IN:
abaabayour program should create the file PAL.OUT:
Your program should look for the file PAL.IN in the current directory and create the file PAL.OUT also in the current directory. The source file containing the program written by you should be named PAL.???, where ??? are substituted by at most three-letter abbreviation of the programming language used. The same program in an executable form should be written in a file PAL.EXE.