a879: Hidden Palindrome
Tags : DP Divide & Conquer 回文 字串 巢狀迴圈 矩陣 累加 遞迴
Accepted rate : 16人/17人 ( 94% ) [非即時]
評分方式:
Tolerant

最近更新 : 2022-11-16 15:22

Content

A palindrome is a word which is the same when read forwards as it is when read backwards. For example, "mom" and "anna" are two palindromes. A word which has just one letter, such as "a", is also a palindrome. Given a word, what is the longest palindrome that is contained in the word? That is, what is the longest palindrome that we can obtain, if we are allowed to delete characters from the beginning and/or the end of the string?

Input

The input will consist of one line, containing a sequence of at least 1 and at most 40 lowercase letters.

Output

Output the total number of letters of the longest palindrome contained in the input word.

Sample Input #1
banana
Sample Output #1
5
Sample Input #2
abracadabra
Sample Output #2
3
Sample Input #3
abba
Sample Output #3
4
測資資訊:
記憶體限制: 64 MB
公開 測資點#0 (20%): 1.0s , <1K
公開 測資點#1 (20%): 1.0s , <1K
公開 測資點#2 (20%): 1.0s , <1K
公開 測資點#3 (20%): 1.0s , <1K
公開 測資點#4 (20%): 1.0s , <1K
Hint :

自定義一個函數去找一個字串是不是palindrome

Tags:
DP Divide & Conquer 回文 字串 巢狀迴圈 矩陣 累加 遞迴
出處:
CCC2016 [管理者:
issin@g.puic... (冼一心老師)
]


ID User Problem Subject Hit Post Date
沒有發現任何「解題報告」