HDU 3068 Max retrieval (Manacher)

Source: Internet
Author: User

HDU 3068 Max retrieval (Manacher)
Question

A lowercase English character a, B, c... Returns the length of the longest input string in S.
The same string is used for both positive and negative reads, such as aba and abba.

Ideas

Insert special characters into the middle of every two characters in the s string to realize that each input string is an odd number, and then use the manacher algorithm to solve the problem.

Code
# Include

  
   
# Include

   
    
# Include

    
     
# Include

     
      
# Include

      
        Using namespace std; const int N = 110009; char s [N], t [N <1]; int p [N <1]; int manacher (int len) {int id = 1, mx = 0; p [0] = 1; for (int I = 1; I 
       
         I) p [I] = min (mx-I, p [2 * id-I]); else p [I] = 1; while (t [I + p [I] = t [I-p [I]) p [I] ++; if (mx <p [I] + I) {mx = p [I] + I; id = I ;}} int ans = p [1]; for (int I = 1; I 
         
        
      

     

    

   

  

Related Article

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.