#P9364. Longest Perfect Word
Longest Perfect Word
Longest Perfect Word
Problem Statement: You are given n strings and are required to determine 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 \). Note that every substring of a substring of a string is also a substring of the original string.
Since any substring of an input string is itself a perfect word, the problem reduces to finding the maximum length among all the given strings.
inputFormat
The first line contains an integer \( n \) representing the number of strings.
Each of the following \( n \) lines contains one non-empty string.
outputFormat
Output a single integer representing the length of the longest perfect word.
sample
3
a
b
ab
2