You are given nn strings and required to find the length of the longest perfect word.
A string t is called a perfect word, if and only if every non-empty substring of t appears in the given strings.
A string s is called a substring of t if and only if it can be obtained by removing several (possibly zero) characters from the beginning or end of t.
Input
The first line contains a single integer n (1≤n≤10^5).
Each of the next nn lines contains a string consisting of lowercase English letters.
It is guaranteed that the total length of the given strings is no more than 10^5.
Output
Output an integer, representing the length of the longest perfect word.
Example
input
4
a
t
b
ab
output
2
题意:找出最大长度的一个字符串,他的字串全部出现过
解析:我们输入时候先用map记录每个字符出现,然后暴力n个字符串的每个字串,因为题目中说n个字符串总长度最大10的5次,枚举长度为1,2,3....n的字串,操作次数n+n/2+n/3+n/4+....+1,是调和级数,复杂度是O(N)的,因此没有问题,暴力即可
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)