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

建议使用的浏览器:

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

2334:Simple prefix compression

题目描述
Many databases store the data in the character fields (and especially indices) using prefix compression. This technique compresses a sequence of strings A1, ..., AN by the following method: if there are strings Ai = ai,1ai,2...ai,p and Ai + 1 = ai+1,1ai+1,2...ai+1,q
such that for some j ≤ min(p, q) ai,1 = ai+1,1, ai,2 = ai+1,2, ... ai,j = ai+1,j, then the second string is stored as [j]ai+1,j+1ai+1,j+2... ai+1,q, where [j] is a single character with code j.

If j = 0, that is, strings do not have any common prefix, then the second string is prefixed with zero byte, and so the total length actually increases.


Constraints
1 ≤ N ≤ 10000, 1 ≤ length(Ai) ≤ 255.
输入解释
First line of input contains integer number N, with following N lines containing strings A1 ... AN
输出解释
Output must contain a single integer -- minimal total length of compressed strings.
输入样例
3
abc
atest
atext
输出样例
11

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

源链接: POJ-2334

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

共提交 0

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