Submit | All submissions | Best solutions | Back to list |
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
|
|||||||
2024-08-19 16:12:16
Use hash and binary search can get AC! |
|||||||
2024-02-18 11:37:10
crazy time limit |
|||||||
2023-10-05 11:57:04
O(n log n) SA can get AC,even with gcc,but it's not easy because of the time limit. |
|||||||
2023-06-14 10:34:29
SAM get WA on #test 10, I find it because of char char c= 'a' + 27+4; (int) ( c ) equals -128 ,resulting in RE |
|||||||
2021-04-14 07:35:37
good luck! |
|||||||
2020-11-28 22:42:25 Leandro Vianna
I got TLE with gcc but AC with clang. O(n lg n). |
|||||||
2020-08-25 21:03:02
Solved with O(nlogn) suffix array and O(nlogn) post-processing, but only using clang compiler, got TLE with gcc... Last edit: 2020-08-25 21:03:38 |
|||||||
2019-05-22 00:23:50
AC with O(n) Suffix Array. Time limit is so strict. Any extra log factor while traversing the LCP array gives TLE. I've used a deque while traversing the LCP array for finding the ans. |
|||||||
2018-07-29 10:26:13
time limit is bullshit, comon, increase it some Last edit: 2018-07-29 10:26:45 |
|||||||
2018-06-15 16:01:31
Can I use "while(scanf("%s",ch))!=EOF)" for input? It was always TLE... |