Canadian Computing Competition: 1997 Stage 2, Day 1, Problem 1
A palindrome is a sequence of characters that reads the same forwards and backwards. e.g. RADAR
, MADAMIMADAM
.
You are to write a program which finds the longest palindrome in a given string of characters.
Input
The input will begin with a line containing one positive integer
Output
Your program should output a pair of lines for each test case with the palindrome on the first line and the length of the palindrome on the second.
In the event of a tie for longest, output the palindrome that appears earlier in the string.
Sample Input
Copy
1
AHAHJHFYUBNMLOIUYTRERTYUIOLMNBAGWOIS
Sample Output
Copy
BNMLOIUYTRERTYUIOLMNB
21
Comments