10071_PhylogeneticTreesInherited

2022-5-16 18:16| 发布者: Hocassian| 查看: 78| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-3-89504515033199-Problem List-采集的数据-后羿采集器.html

Pro.ID

10071

Title

Phylogenetic Trees Inherited

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=10071

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 400/200 MS (Java/Others)     Memory Limit: 32768/32768 K (Java/Others)
  • 描述

    Among other things, Computational Molecular Biology deals with processing genetic sequences. Considering the evolutionary relationship of two sequences, we can say that they are closely related if they do not differ very much. We might represent the relationship by a tree, putting sequences from ancestors above sequences from their descendants. Such trees are called phylogenetic trees.

    Whereas one task of phylogenetics is to infer a tree from given sequences, we'll simplify things a bit and provide a tree structure - this will be a complete binary tree. You'll be given the n leaves of the tree. Sure you know, n is always a power of 2. Each leaf is a sequence of amino acids (designated by the one-character-codes you can see in the figure). All sequences will be of equal length l. Your task is to derive the sequence of a common ancestor with minimal costs.

    Amino Acid

    Alanine AlaA
    Arginine ArgR
    Asparagine AsnN
    Aspartic Acid AspD
    Cysteine CysC
    Glutamine GlnQ
    Glutamic Acid GluE
    Glycine GlyG
    Histidine HisH
    Isoleucine IleI

    Amino Acid

    Leucine LeuL
    Lysine LysK
    Methionine MetM
    Phenylalanine PheF
    Proline ProP
    Serine SerS
    Threonine ThrT
    Tryptophan TrpW
    Tyrosine TyrY
    Valine ValV

    The costs are determined as follows: every inner node of the tree is marked with a sequence of length l, the cost of an edge of the tree is the number of positions at which the two sequences at the ends of the edge differ, the total cost is the sum of the costs at all edges. The sequence of a common ancestor of all sequences is then found at the root of the tree. An optimal common ancestor is a common ancestor with minimal total costs.

    输入

    The input file contains several test cases. Each test case starts with two integers n and l, denoting the number of sequences at the leaves and their length, respectively. Input is terminated by n=l=0. Otherwise, 1 ≤ n ≤ 1024 and 1 ≤ l ≤ 1000. Then follow n words of length l over the amino acid alphabet. They represent the leaves of a complete binary tree, from left to right.

    输出

    Description

    Among other things, Computational Molecular Biology deals with processing genetic sequences. Considering the evolutionary relationship of two sequences, we can say that they are closely related if they do not differ very much. We might represent the relationship by a tree, putting sequences from ancestors above sequences from their descendants. Such trees are called phylogenetic trees.

    Whereas one task of phylogenetics is to infer a tree from given sequences, we'll simplify things a bit and provide a tree structure - this will be a complete binary tree. You'll be given the n leaves of the tree. Sure you know, n is always a power of 2. Each leaf is a sequence of amino acids (designated by the one-character-codes you can see in the figure). All sequences will be of equal length l. Your task is to derive the sequence of a common ancestor with minimal costs.

    Amino Acid

    Alanine AlaA
    Arginine ArgR
    Asparagine AsnN
    Aspartic Acid AspD
    Cysteine CysC
    Glutamine GlnQ
    Glutamic Acid GluE
    Glycine GlyG
    Histidine HisH
    Isoleucine IleI

    Amino Acid

    Leucine LeuL
    Lysine LysK
    Methionine MetM
    Phenylalanine PheF
    Proline ProP
    Serine SerS
    Threonine ThrT
    Tryptophan TrpW
    Tyrosine TyrY
    Valine ValV

    The costs are determined as follows: every inner node of the tree is marked with a sequence of length l, the cost of an edge of the tree is the number of positions at which the two sequences at the ends of the edge differ, the total cost is the sum of the costs at all edges. The sequence of a common ancestor of all sequences is then found at the root of the tree. An optimal common ancestor is a common ancestor with minimal total costs.

    Input

    The input file contains several test cases. Each test case starts with two integers n and l, denoting the number of sequences at the leaves and their length, respectively. Input is terminated by n=l=0. Otherwise, 1 ≤ n ≤ 1024 and 1 ≤ l ≤ 1000. Then follow n words of length l over the amino acid alphabet. They represent the leaves of a complete binary tree, from left to right.

    Output

    For each test case, output a line containing some optimal common ancestor and the minimal total costs.

    Sample Input

    4 3
    AAG
    AAA
    GGA
    AGA

    4 3
    AAG
    AGA
    AAA
    GGA

    4 3
    AAG
    GGA
    AAA
    AGA

    4 1
    A
    R
    A
    R

    2 1
    W
    W

    2 1
    W
    Y

    1 1
    Q

    0 0

    Sample Output

    AGA 3
    AGA 4
    AGA 4
    R 2
    W 0
    Y 1
    Q 0

    Source

    样例输入

    4 3
    AAG
    AAA
    GGA
    AGA

    4 3
    AAG
    AGA
    AAA
    GGA

    4 3
    AAG
    GGA
    AAA
    AGA

    4 1
    A
    R
    A
    R

    2 1
    W
    W

    2 1
    W
    Y

    1 1
    Q

    0 0

    样例输出

    AGA 3
    AGA 4
    AGA 4
    R 2
    W 0
    Y 1
    Q 0

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部