atcoder#ABC287E. [ABC287E] Karuta
[ABC287E] Karuta
Score : points
Problem Statement
You are given strings consisting of lowercase English letters. Let be the -th of them.
For two strings and , is defined to be the maximum integer that satisfies all of the following conditions:
- The lengths of and are both at least .
- For all integers between and , inclusive, the -th character of and that of are equal.
Find the following value for all :
- $\displaystyle \max_{i \neq j} \mathrm{LCP}(S_i, S_j)$
Constraints
- is an integer.
- is a string of length at least consisting of lowercase English letters .
- The sum of lengths of is at most .
Input
The input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain $\displaystyle \max_{i \neq j} \mathrm{LCP}(S_i, S_j)$.
3
abc
abb
aac
2
2
1
$\mathrm{LCP}(S_1, S_2) = 2, \mathrm{LCP}(S_1, S_3) = 1$, and .
11
abracadabra
bracadabra
racadabra
acadabra
cadabra
adabra
dabra
abra
bra
ra
a
4
3
2
1
0
1
0
4
3
2
1