#abc287e. E - Karuta
E - Karuta
Score : points
问题描述
你将获得 个由小写英文字母组成的字符串。设第 个()字符串为 。
对于两个字符串 和 ,定义 为满足以下所有条件的最大整数 :
- 字符串 和 的长度均至少为 。
- 对于所有在 到 之间(含)的整数 ,第 个字符的 值和 值相等。
求出对所有 的以下值:
- $\displaystyle \max_{i \neq j} \mathrm{LCP}(S_i, S_j)$
以上为通义千问 qwen-max 翻译,仅供参考。
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)$.
Sample Input 1
3
abc
abb
aac
Sample Output 1
2
2
1
$\mathrm{LCP}(S_1, S_2) = 2, \mathrm{LCP}(S_1, S_3) = 1$, and .
Sample Input 2
11
abracadabra
bracadabra
racadabra
acadabra
cadabra
adabra
dabra
abra
bra
ra
a
Sample Output 2
4
3
2
1
0
1
0
4
3
2
1
update @ 2024/3/10 12:00:18