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

建议使用的浏览器:

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

2817:WordStack

题目描述
As editor of a small-town newspaper, you know that a substantial number of your readers enjoy the daily word games that you publish, but that some are getting tired of the conventional crossword puzzles and word jumbles that you have been buying for years. You decide to try your hand at devising a new puzzle of your own.

Given a collection of N words, find an arrangement of the words that divides them among N lines, padding them with leading spaces to maximize the number of non-space characters that are the same as the character immediately above them on the preceding line. Your score for this game is that number.
输入解释
Input data will consist of one or more test sets.

The first line of each set will be an integer N (1 <= N <= 10) giving the number of words in the test case. The following N lines will contain the words, one word per line. Each word will be made up of the characters 'a' to 'z' and will be between 1 and 10 characters long (inclusive).

End of input will be indicated by a non-positive value for N .
输出解释
Your program should output a single line containing the maximum possible score for this test case, printed with no leading or trailing spaces.
输入样例
5 
abc 
bcd 
cde 
aaa 
bfcde 
0
输出样例
8
提示
Note: One possible arrangement yielding this score is:
aaa 

abc
bcd
cde
bfcde

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

题目来源 Mid-Atlantic 2005

源链接: POJ-2817

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

共提交 0

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