首页 > 其他 > 详细

SPOJ LCS2 Longest Common Substring II

时间:2017-02-16 01:31:36      阅读:267      评论:0      收藏:0      [点我收藏+]

 

A string is finite sequence of characters over a non-empty finite set Σ.

In this problem, Σ is the set of lowercase letters.

Substring, also called factor, is a consecutive sequence of characters occurrences at least once in a string.

Now your task is a bit harder, for some given strings, find the length of the longest common substring of them.

Here common substring means a substring of two or more strings.

Input

The input contains at most 10 lines, each line consists of no more than 100000 lowercase letters, representing a string.

Output

The length of the longest common substring. If such string doesn‘t exist, print "0" instead.

Example

Input:
alsdfkjfjkdsal
fdjskalajfkdsla
aaaajfaaaa

Output:
2

Notice: new testcases added

 

就是求多个字符串的最长公共子串

后缀自动机

用第一个串建后缀自动机,然后在这个自动机上花式转移。

solve()里面tmp没初始化,调了半天……

 

SPOJ LCS2 Longest Common Substring II

原文:http://www.cnblogs.com/SilverNebula/p/6403994.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!