#P3649. [APIO2014] 回文串

    ID: 1430 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>字符串2014APIO后缀自动机,SAM概率论,统计后缀数组,SA回文自动机 PAM

[APIO2014] 回文串

Description

You are given a string ss consisting of lowercase Latin letters. We define the existence value of a substring of ss as the number of occurrences of this substring in ss multiplied by its length.

For the given string ss, find the maximum existence value among all palindromic substrings.

Input Format

One line, a non-empty string ss consisting of lowercase Latin letters (a~z).

Output Format

Output a single integer, the maximum existence value among all palindromic substrings.

abacaba

7

www
4

Hint

Sample Explanation 1

Use s\lvert s \rvert to denote the length of string ss.

A substring of a string s1s2sss_1 s_2 \dots s_{\lvert s \rvert} is a non-empty string sisi+1sjs_i s_{i+1} \dots s_j, where 1ijs1 \leq i \leq j \leq \lvert s \rvert. Every string is a substring of itself.

A string is called a palindrome if and only if it reads the same from left to right and from right to left.

In this sample, there are 77 palindromic substrings a, b, c, aba, aca, bacab, abacaba. Their existence values are 4,2,1,6,3,5,74, 2, 1, 6, 3, 5, 7, respectively.

Therefore, the maximum existence value among palindromic substrings is 77.

Subtasks

  • Subtask 1 (8 points): 1s1001 \leq \lvert s \rvert \leq 100.
  • Subtask 2 (15 points): 1s10001 \leq \lvert s \rvert \leq 1000.
  • Subtask 3 (24 points): 1s100001 \leq \lvert s \rvert \leq 10000.
  • Subtask 4 (26 points): 1s1000001 \leq \lvert s \rvert \leq 100000.
  • Subtask 5 (27 points): 1s3000001 \leq \lvert s \rvert \leq 300000.

Translated by ChatGPT 5