11311: [yosupo] String - Longest Common Substring
[Creator : ]
Description
Strings $S$ and $T$ is given. Find a longest common substring of $S$ and $T$.
Input
$S$
$T$
$T$
Output
Output $a,b,c,d$ when a longest common substring can be taken as $(S_a, \ldots, S_{b-1})$ and $(T_c, \ldots, T_{d-1})$.
$a$ $b$ $c$ $d$
Here, $S_i$ represents the $(1+i)$-th character of $S$, and $T_j$ represents the $(j+1)$-th character of $T$.
If the longest common substring is empty, print:
$0$ $0$ $0$ $0$
Constraints
- $1 \leq |S|, |T| \leq 5\times 10^{5}$
- Each character of $S$, $T$ is lowercase English letters.
- Each character of $S$, $T$ is lowercase English letters.
Sample 1 Input
abcdef
abcxdef
Sample 1 Output
0 3 0 3
`3 6 4 7` is also accepted.
Sample 2 Input
aaa
bbbb
Sample 2 Output
0 0 0 0
Sample 3 Input
abcabcabc
cabcabcab
Sample 3 Output
0 8 1 9
aaa
aaaaa
0 3 2 5
Sample 4 Input
abcdef
abcxdef
Sample 4 Output
3 6 4 7