#P3667. [USACO17OPEN] Bovine Genomics G
[USACO17OPEN] Bovine Genomics G
题目描述
Farmer John owns cows with spots and cows without spots. Having just completed a course in bovine genetics, he is convinced that the spots on his cows are caused by mutations in the bovine genome.
At great expense, Farmer John sequences the genomes of his cows. Each genome is a string of length built from the four characters A, C, G, and T. When he lines up the genomes of his cows, he gets a table like the following, shown here
for and :
Positions: 1 2 3 4 5 6 7 8
Spotty Cow 1: A A T C C C A T
Spotty Cow 2: A C T T G C A A
Spotty Cow 3: G G T C G C A A
Plain Cow 1: A C T C C C A G
Plain Cow 2: A C T C G C A T
Plain Cow 3: A C T T C C A T
Looking carefully at this table, he surmises that the sequence from position 2 through position 5 is sufficient to explain spottiness. That is, by looking at the characters in just these these positions (that is, positions ), Farmer John can predict which of his cows are spotty and which are not. For example, if he sees the characters GTCG in these locations, he knows the cow must be spotty.
Please help FJ find the length of the shortest sequence of positions that can explain spottiness.
输入格式
The first line of input contains () and (). The next lines each contain a string of characters; these describe the genomes of the spotty cows.
The final lines describe the genomes of the plain cows. No spotty cow has the same exact genome as a plain cow.
输出格式
Please print the length of the shortest sequence of positions that is sufficient to explain spottiness. A sequence of positions explains spottiness if the spottiness trait can be predicted with perfect accuracy among Farmer John's population of cows by looking at just those locations in the genome.
题目大意
题目描述
Farmer John 拥有 头有斑点的牛和 头没有斑点的牛。他刚刚完成了一门关于牛遗传学的课程,并确信他牛身上的斑点是由牛基因组中的突变引起的。
Farmer John 花费巨资对他的牛进行了基因组测序。每个基因组是一个由字符 A、C、G 和 T 组成的长度为 的字符串。当他将牛的基因组排列起来时,会得到如下表格,这里展示的是 和 的情况:
位置: 1 2 3 4 5 6 7 8
斑点牛 1:A A T C C C A T
斑点牛 2:A C T T G C A A
斑点牛 3:G G T C G C A A
普通牛 1:A C T C C C A G
普通牛 2:A C T C G C A T
普通牛 3:A C T T C C A T
仔细观察这个表格后,他推测从位置 2 到位置 5 的序列足以解释斑点现象。也就是说,通过仅查看这些位置(即位置 )的字符,Farmer John 可以预测哪些牛是有斑点的,哪些是没有斑点的。例如,如果他在这些位置看到字符 GTCG,他就知道这头牛一定是有斑点的。
请帮助 Farmer John 找到能够解释斑点现象的最短位置序列的长度。
输入格式
输入的第一行包含 ()和 ()。接下来的 行每行包含一个长度为 的字符串,这些字符串描述了斑点牛的基因组。
最后的 行描述了普通牛的基因组。没有任何一头斑点牛的基因组与普通牛的完全相同。
输出格式
请输出能够解释斑点现象的最短位置序列的长度。如果通过查看基因组中这些位置的字符,可以在 Farmer John 的牛群中完美准确地预测斑点性状,那么这个位置序列就解释了斑点现象。
3 8
AATCCCAT
ACTTGCAA
GGTCGCAA
ACTCCCAG
ACTCGCAT
ACTTCCAT
4