[Bzoj 3676] [Uoj #103] "APIO2014" palindromes palindrome string suffix array +manachar

Source: Internet
Author: User

Give you a string SS consisting of lowercase Latin letters. We define the existence value of a substring of the SS multiplied by the number of occurrences of the substring in the SS by the length of the substring.

For this string SS to you, ask for the maximum existence value in all palindrome substrings.
Input format

Row, a non-empty string SS consisting of a lowercase Latin alphabet (a~z).
Output format

Outputs an integer representing the maximum presence value in all palindrome substrings.
Sample One
Input

Abacaba

Output

7

Explanation

The length of the string SS is represented by ∣s∣∣s∣.

A substring of a string s1s2...s∣s∣s1s2...s∣s∣ is a non-empty string sisi+1...sjsisi+1...sj, where 1≤i≤j≤∣s∣1≤i≤j≤∣s∣. Each string is its own substring.

A string is called a palindrome and is identical only if the string is read from left to right and read from right to left.

In this example, there are 77 palindrome string 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.

So the largest existence value in Palindrome substring is 77.
Example Two
Input

Www

Output

4

Restrictions and conventions

The first subtask has a total of 8 points, satisfying 1≤∣s∣≤1001≤∣s∣≤100.

The second subtask has a total of 15 points, satisfying 1≤∣s∣≤10001≤∣s∣≤1000.

The third subtask has a total of 24 points, satisfying 1≤∣s∣≤100001≤∣s∣≤10000.

The fourth sub-task has a total of 26 points to meet 1≤∣s∣≤1000001≤∣s∣≤100000.

The fifth sub-task has a total of 27 points to meet 1≤∣s∣≤3000001≤∣s∣≤300000.

Time limit: 1

[Bzoj 3676] [Uoj #103] "APIO2014" palindromes palindrome string suffix array +manachar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.