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

建议使用的浏览器:

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

1583:DNA Assembly

题目描述
Farmer John has performed DNA sequencing on his prize milk-producing cow, Bessie DNA sequences are ordered lists (strings) containing the letters 'A', 'C', 'G', and 'T'.

As is usual for DNA sequencing, the results are a set of strings that are sequenced fragments of DNA, not entire DNA strings. A pair of strings like 'GATTA' and 'TACA' most probably represent the string 'GATTACA' as the overlapping characters are merged, since they were probably duplicated in the sequencing process.

Merging a pair of strings requires finding the greatest overlap between the two and then eliminating it as the two strings are concatenated together. Overlaps are between the end of one string and beginning of another string, NOT IN THE MIDDLE OF A STRING.

By way of example, the strings 'GATTACA' and 'TTACA' overlap completely. On the other hand, the strings 'GATTACA' and 'TTA' have no overlap at all, since the matching characters of one appear in the middle of the other, not at one end or the other. Here are some examples of merging strings, including those with no overlap:



  GATTA + TACA -> GATTACA
  TACA + GATTA -> TACAGATTA
  TACA + ACA -> TACA
  TAC + TACA -> TACA
  ATAC + TACA -> ATACA
  TACA + ACAT -> TACAT
Given a set of N (2 <= N <= 7) DNA sequences all of whose lengths are in the range 1..7, find and print length of the shortest possible sequence obtainable by repeatedly merging all N strings using the procedure described above. All strings must be merged into the resulting sequence.
输入解释
The input consists of multiple test cases.
Each test case :
Line 1: A single integer N

Lines 2..N+1: Each line contains a single DNA subsequence
End of file.
输出解释
For each pair of input output the length of the shortest possible string obtained by merging the subsequences. It is always possible – and required – to merge all the input strings to obtain this string.
输入样例
4
GATTA
TAGG
ATCGA
CGCAT
输出样例
13


Explanation of the sample: 

Such string is "CGCATCGATTAGG".
来自杭电HDUOJ的附加信息
Recommend lcy

该题目是Virtual Judge题目,来自 杭电HDUOJ

题目来源 冬练三九之二

源链接: HDU-1583

最后修改于 2020-10-25T22:46:13+00:00 由爬虫自动更新

共提交 271

通过率 62.73%
时间上限 内存上限
1000/1000MS(Java/Others) 32768/32768K(Java/Others)