#P9364. [ICPC2022 Xi'an R] Perfect Word

[ICPC2022 Xi'an R] Perfect Word

题目描述

You are given nn strings and required to find the length of the longest perfect word.

A string tt is called a perfect word, if and only if every non-empty substring of tt appears in the given strings.

A string ss is called a substring of tt if and only if it can be obtained by removing several (possibly zero) characters from the beginning or end of tt.

输入格式

The first line contains a single integer nn (1≤n≤1051 \leq n \leq 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 10510 ^ 5.

输出格式

Output an integer, representing the length of the longest perfect word.

题目大意

题目描述

给定 nn 个字符串,你需要找到最长的「完美单词」。

字符串 tt 称为「完美单词」,当且仅当它的所有非空子串都出现在给定的字符串中。

字符串 ss 称为 tt 的子串,当且仅当 ss 可由 tt 在开头和结尾分别删去零个或若干个字符得到。

1≤n≤1051\leq n\leq 10 ^ 5,字符串仅由小写字母组成,且总长不超过 10510 ^ 5。

输入格式

第一行一个整数 nn。

接下来 nn 行,每行一个字符串。

输出格式

输出一行一个整数表示最长的「完美单词」的长度。

4
a
t
b
ab

2

提示

Source: The 2022 ICPC Asia Xi'an Regional Contest Problem G.

Author: MonkeyKing.