当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3852:String LD

题目描述
Stringld (left delete) is a function that gets a string and deletes its leftmost character (for instance Stringld(“acm”) returns “cm”).

You are given a list of distinct words, and at each step, we apply stringld on every word in the list. Write a program that determines the number of steps that can be applied until at least one of the conditions become true:

1) A word becomes empty string, or
2) a duplicate word is generated.

For example, having the list of words aab, abac, and caac, applying the function on the input for the first time results in ab, bac, and aac. For the second time, we get b, ac, and ac. Since in the second step, we have two ac strings, the condition 2 is true, and the output of your program should be 1. Note that we do not count the last step that has resulted in duplicate string. More examples are found in the sample input and output section.
输入解释
There are multiple test cases in the input. The first line of each test case is n (1 <= n <= 100), the number of words.
Each of the next n lines contains a string of at most 100 lower case characters.
The input terminates with a line containing 0.
输出解释
For each test case, write a single line containing the maximum number of stringld we can call.
输入样例
4
aaba
aaca
baabcd
dcba
3
aaa
bbbb
ccccc
0
输出样例
1
2

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 Tehran 2009

源链接: POJ-3852

最后修改于 2020-10-29T07:13:43+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536