#P4555. [国家集训队] 最长双回文串

    ID: 3517 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>字符串线段树WC/CTSC/集训队枚举,暴力Manacher 算法

[国家集训队] 最长双回文串

Description

A string that reads the same forward and backward is called a palindrome. For example, acbca is a palindrome, while abc is not: the forward order is abc, and the reverse is cba, which are not the same.

Given a string SS of length nn, find the longest double palindromic substring TT of SS, that is, TT can be divided into two parts X,YX, Y (with X,Y1|X|, |Y| \ge 1) and both XX and YY are palindromes.

Input Format

One line containing a string SS consisting of lowercase English letters.

Output Format

One line with a single integer, the length of the longest double palindromic substring.

baacaabbacabb
12

Hint

Sample Explanation

Starting from the second character, the string aacaabbacabb can be split into two parts aacaa and bbacabb, and both are palindromes.

Constraints

For 100%100\% of the testdata, 2S1052 \le |S| \le 10^5.

2018.12.10, 2018.12.15: Thanks to @Ycrpro for providing two hack testdata sets.

Translated by ChatGPT 5