DWITE '11 R1 #5 - Tattarrattat

View as PDF

Submit solution

Points: 10
Time limit: 1.0s
Memory limit: 64M

Problem type
DWITE, October 2011, Problem 5

A palindrome is a word that is the same backwards as it is forwards (e.g. tattarrattat). Even though most words aren't palindromes, you can always remove letters from the word to make it a palindrome (remember that all words of length 0 or 1 are palindromes). For example, farmer is not a palindrome, but removing a few letters yields rer, which is a palindrome.

Your task is to determine the length of the longest palindrome you can get from a word by removing zero or more letters.

The input will contain 5 test cases, each a line with a string S consisting of no more than 255 alphanumeric characters (a-z, A-Z, 0-9). There are no spaces.

For each test case, print one line, each a number — the length of the longest palindrome you can get by removing zero or more letters from the corresponding string.

Sample Input

tattarrattat
sounds
cool

Sample Output

12
3
2

Problem Resource: DWITE

Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported

Comments

There are no comments at the moment.