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

建议使用的浏览器:

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

2949:Word Rings

Special Judge 特殊评判
题目描述
A word ring is a sequence of words where the last two letters of each word are the same as the first two letters of the next word (and the last two letters of the last word are the same as the first two letters of the first word). For example, the following sequence is a word ring:

intercommunicational
alkylbenzenesulfonate
tetraiodophenolphthalein

Your task is to write a program that, given a list of words, finds a word ring. You have to make the word ring as impressive as possible: the average length of the words in the ring has to be as large as possible. In the above example, the average length is (20 + 21 + 24)/3 ≈ 21.6666 , which makes it somewhat impressive. Note that each word can be used at most once in the ring, and the ring can consist of a single word.
输入解释
The input contains several blocks of test cases. Each case begins with a line containing a single integer 1 ≤ n ≤ 100000 , the number of possible words that can be used. The next n lines contain these words. The words contain only the characters `a'-`z' and the length of each word is at most 1000.

The input is terminated by a block with n = 0 .

输出解释
For each test case in the input, you have to output a single number on a separate line: the maximum average length of a ring composed from (a subset of) the words given in the input. The average length should be presented as a real number with two digits of precision. If it is not possible to compose a ring from these words, then output `No solution.' (without quotes). To avoid rounding problems, we accept solutions with a maximum of ±0.01 error.
输入样例
3
intercommunicational
alkylbenzenesulfonate
tetraiodophenolphthalein
0
输出样例
21.66
提示
Huge input file, 'scanf' recommended to avoid TLE.

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

题目来源 Central Europe 2005

源链接: POJ-2949

最后修改于 2020-10-29T06:48:15+00:00 由爬虫自动更新

共提交 0

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