[codevs3160] Longest common substring problem solving report | suffix automata

Source: Internet
Author: User

Gives a string of two lowercase letters to find the length of their longest common substring.

The example is not more familiar. It looks like it was done once with a suffix array.

And then found that the suffix automata really good writing ah ... (Of course, when I learned the suffix array, I think so ...)

  

This problem directly puts the first string in the suffix automaton.

The second string on the top of the match, but pay attention to match the time can not be confused ...

  

Just started to write something like KMP ... Think wrong.

After all, some nodes are not in the right depth.

Later, however, we could use a variable tem to hold the current length value.

If you can continue the match, this value is +1.

Otherwise, the fail pointer is started to recede until it is returned to a location where the current character is present in its child nodes.

Then tem = Depth of this node +1

That's what I understand. By observing the process of the suffix automaton, we can find

The node pointed to by the fail pointer is a deeply determined node, and if the depth is indeterminate, a new depth-determined point is created to point to it

So the depth of the node must be the right one, given the return fail pointer.

However, its sub-nodes are not necessarily ...

This is also why the front can match the time can not be directly used in length ...

[codevs3160] Longest common substring problem solving report | suffix automata

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.