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