2016--3--16 KMP Exercises

Source: Internet
Author: User
Tags repetition

1. Portal: http://begin.lydsy.com/JudgeOnline/problem.php?id=2725

To find the number of occurrences of a string in another string

Problem: KMP (Nude)

2. Portal: http://begin.lydsy.com/JudgeOnline/problem.php?id=2732

The main topic: give you a string, let you find the maximum repetition period (the maximum period does not coincide with itself)

Solution: KMP or Extended KMP (but I did not use this method), I use KMP, but always WA, the original is to ask the next array to write the if (hand-shaking life).

OK, write a puzzle: use KMP to find the next array, and then go to recursive next[n], because J=next[next[n]] has been next down until its next is 0 ans+=n-j;

This allows you to find the maximum repetition cycle that is not the same as the mother string, but there is one more problem when you ask for j, it is possible for the recursive time to be n^2, so it is better to change the value of next at each recursion (see Code);

3. Portal: http://begin.lydsy.com/JudgeOnline/problem.php?id=2726

The main idea: to give a matrix of letters, to find a minimum sub-matrix, so that the sub-matrix of the infinite copy expansion after the matrix contains the original matrix, for example
His smallest repeating sub-matrix is AB

2016--3--16 KMP Exercises

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.