| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 128 MB | 11 | 3 | 3 | 100.000% |
A toponym is the name given to a city, village, river, mountain etc. Very often, in the Republic of Moldova, one can find toponyms which are very similar. For example, Orhei and Orheiul Vechi; Jora de Sus, Jora de Mijloc and Jora de Jos.
As a rule, every toponym represents a sequence consisting of the characters A, B, C, ..., Z, a, b, c, ..., z and blank character. In toponyms there can not appear sequences of two or more consecutive blanks. Toponyms have no leading or trailing blanks. The subsequences consisting of the first $m$ characters of the toponym is called a prefix of length $m$. For example, the subsequence Jora, is a prefix of length $m = 4$ of the toponym Jora de Mijloc.
For example, for the set of toponyms $T$ = {Jora de Sus, Jora de Mijloc, Jora de Jos}, the level of complexity $Lc(T) = 24$.
Write a program which, for a given set of toponyms $S,ドル find the subset $T,ドル $T \subseteq S,ドル with the maximal level of complexity.
The input contains on the first line an integer $n$ - number of toponyms in $S$. Each of the next $n $lines of the input file contains a toponym. Each toponym is a string of characters A, B, C, …, Z, a, b, c, …, z and the blank.
The output must contain a single line with an integer representing the maximal level of complexity $Lc(T)$.
7 Jora de Sus Orhei Jora de Mijloc Joreni Jora de Jos Japca Orheiul Vechi
24