HDU 4300 Clairewd's message (KMP)

Source: Internet
Author: User
Tags bitset

HDU 4300 Clairewd's message (KMP)

Question: Give You a conversion table with 26 letters, convert 'A' to the first letter, and convert 'B' to the second... and so on. The second line gives you a ciphertext + plaintext string, and the plaintext may be incomplete, so that you can find the smallest possible solution.

Train of Thought: the train of thought is not difficult to think about, it is to convert the ciphertext into plain text, and then start to KMP the original string from the middle until the last character returns the matching length. The matching length is the shortest plaintext length.

For details, see the code:

#include
 
  #include
  
   #include#include
   
    #include
    
     #include
     
      #include
      
       #include
       
        #include
        
         #include
         
          #include
          
           #include
           
            #include
            
             #include
             #include
              
               #define Max(a,b) ((a)>(b)?(a):(b))#define Min(a,b) ((a)<(b)?(a):(b))using namespace std;typedef long long ll;typedef long double ld;const ld eps = 1e-9, PI = 3.1415926535897932384626433832795;const int mod = 1000000000 + 7;const int INF = 0x3f3f3f3f;// & 0x7FFFFFFFconst int seed = 131;const ll INF64 = ll(1e18);const int maxn = 1000000 + 10;int n,t,m,f[maxn],ans;char s[maxn],T[maxn];void getfail(char *p, int m) { f[0] = f[1] = 0; for(int i=1;i
               
                

 

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.