Palindrome
InterviewTime limit1sMemory limit1024 MB
Given a string of N uppercase letters, find the fewest replacements needed to make it a palindrome, and print the alphabetically smallest result.
Statement
Kevin earned full marks on the palindrome problem in the qualifying round of the informatics olympiad. His teacher saw this and gave him a harder problem about palindromes of varying lengths.
As with number sequences, a text is called a palindrome if it reads the same forwards and backwards. For example, ABBA is a palindrome because it reads ABBA backwards. ABCD is not a palindrome, since it reads DCBA backwards.
Write a program that finds the minimum number of letter replacements needed to turn a given text into a palindrome.
Input
The first line contains an integer ().
The second line contains a text of uppercase Latin letters (A ... Z).
Output
The first line prints the integer , the minimum number of letters that must be replaced to turn the given text into a palindrome.
The second line prints the resulting palindrome. If several palindromes can be made with the minimum number of replacements, print the alphabetically first one.