LCS2 - Longest Common Substring II

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 all the considered 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


Added by:Bin Jin
Date:2007-09-24
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 CPP

hide comments
2018-06-04 05:14:30
WA on #10, because I forget to update information on the parent tree

Last edit: 2018-06-04 05:26:37
2017-11-03 20:19:21
never mind, submitted, passed until 10 and TLE
2017-11-03 20:04:16
why in the test case the answer is 2?
in second and third line there is the substring "ajf" of length 3!!!!
2017-10-05 11:06:44
I don't know why am I getting WA on TEST 15???
2017-09-19 16:00:31
I found a wrong way to pass the current testcases, and I have found a new testcase can make it WA. Could I submit the new testcase or do something?
2017-09-12 10:53:08
i submited the same solution that has got AC when i used it in the easier version of this problem but now
i got WA on #10 ... does that mean there is something wrong with the testcases of the easier version or what ?
2017-04-23 16:13:42
WA 10 cause of not understand SAM well
2017-03-16 16:31:28
WHY I ALWAYS GET WA ON TEST10??? :(

Last edit: 2017-03-16 16:55:22
2017-03-13 10:49:34
Why always get WA on #10???
2017-01-17 14:52:13
AC with O(N) suffix array :)
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.