Home => ProblemSet => 接龙游戏
Problem2340--接龙游戏

2340: 接龙游戏

Time Limit: 1 Sec  Memory Limit: 128 MB  Submit: 0  Solved: 1
[ Submit ] [ Status ] [ Creator: ][ 参考程序 ]

Description

给出了N个单词,已经按长度排好了序。如果某单词i是某单词j的前缀,i->j算一次接龙(两个相同的单词不能算接龙)。
你的任务是:对于输入的单词,找出最长的龙。

Input

第一行为N(1<=N<=105)。以下N行每行一个单词(由小写组成),已经按长度排序。(每个单词长度<50)

Output

仅一个数,为最长的龙的长度。

Sample Input Copy

5
i
a
int
able
inter

Sample Output Copy

3

HINT

样例:i -> int -> inter,龙的长度为3
1<=N<=105

Source/Category