LCS - Longest Common Substring
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 simple, for two 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 exactly two lines, each line consists of no more than 250000 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 Output: 3
hide comments
|
sleepntsheep:
2023-08-27 15:36:29
O(nlogn) suffix array TLE, too strict time limit? |
|
cubyte:
2022-11-23 07:42:29
A good problem for practicing suffix array.
|
|
rafi22:
2022-05-27 13:26:45
TLE TLE TLE TLE.... bc gaand maar liya is question ne to |
|
wonderfulwhale:
2022-05-24 17:49:35
Suffix Automaton O(n) AC 0.27s Last edit: 2022-05-27 13:12:15 |
|
tr_abhishek:
2021-05-13 10:18:33
TLE TLE TLE TLE.... bc gaand maar liya is question ne to |
|
allenge:
2021-05-08 11:19:16
SuffixAutoMaton O(n) AC 0.04s |
|
treenipples:
2021-02-23 13:59:03
Prefix hash O(nlog^2n) with vector + sorting passed in 0.77s
|
|
sharath1999:
2020-08-04 15:51:03
Suffix automaton worked super quick for me |
|
Lê Thanh Phú:
2020-08-02 10:06:04
Suffix Array O(nlog^2(n)) AC 0.53s |
|
grapo_oranges:
2020-07-07 06:35:02
No need for suffix tree, suffix array is enough to solve this problem, also no need for memory optimization in LCP, it get AC easily.. goodluck O(n log n:) |
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 |