Algorithm title: HDU 4300 clairewd ' s message (expand KMP)

Source: Internet
Author: User

Link:

http://acm.hdu.edu.cn/showproblem.php?pid=4300

The main effect of the topic:

Sends a ciphertext for the string s. The first half of this cipher is encrypted, and the latter part is not encrypted. Now this cipher is intercepted, but a part of the tail of the cipher is lost. For example, if the ciphertext is xxxxzzzz, XXXX is encrypted, zzzz is not encrypted, because the loss of a part of the back, so intercepted content may be xxxxzz, can ensure that the contents of intercepted content is not encrypted must be complete.

Given the password table, which is a string of 26-letter strings, A[0] represents the encrypted letter of a, a[1] denotes the letter after the B is encrypted ... a[25] represents the letter after the z is encrypted.

To restore you to the undamaged ciphertext. In the intercepted content, let the plaintext be the shortest.

Analysis and Summary:

Let's look at the method of violence. Begin the enumeration directly from half of s, and then determine whether the later part of the encryption is matched to the plaintext part.

It turns out that the data is weak and can be violently water.

If not water, the positive solution of this problem should be to expand KMP (data)

First the S all as a cipher, and then the s all converted to plaintext, save as T

At this time, the cipher part of S is all become clear text, and the clear part becomes XXX (do not care what is).

It can then be found that the plaintext portion of the original S is the suffix of s, while the plaintext part of T is the prefix of T.

So, it becomes the longest common prefix of "I....N" with T, which is the naked extension of kmp problem.

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.