青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

superman

聚精會神搞建設 一心一意謀發(fā)展
posts - 190, comments - 17, trackbacks - 0, articles - 0
   :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

ZOJ 1102 - Phylogenetic Trees Inherited

Posted on 2008-04-06 11:13 superman 閱讀(443) 評論(0)  編輯 收藏 引用 所屬分類: ZOJ

Official Solution:

Problem G: Phylogenetic Trees Inherited

The first thing to observe is that the different positions in every sequence are independent of each other. This reduces the tree of sequences to a tree of amino acids. At the root of the tree, or for that matter of any sub-tree, there may be many possible amino acids leading to optimal costs. Suppose, you have calculated for two sub-trees Tl and Tr the sets of amino-acids leading to optimal costs Al and Ar. Adjacent sub-trees Tl and Tr have as their father the node T. Now you want to find the set of amino-acids A that you can mark T with, leading to optimal costs for T.

There are two cases: if the intersection of Al with Ar is non-empty, define A as just this intersection, otherwise define A to be the union of Al and Ar. To see why this is true, observe the extra costs you get, when you assemble T from Tl and Tr. In the first case, you have 0 extra costs when you take an amino-acid from the intersection, but 1 or 2 extra costs when you do not. In the second case, you have 1 extra costs when you take an amino-acid from the union, but 2 extra-costs when you do not. Now, you may want to assemble T not from Tl and Tr but from some other sub-optimal trees. As you can easily verify, this leads to sub-optimal costs for T as well.

This reasoning is carried over straightforwardly to an induction proof and leads to a dynamic programming solution. Since the amino-acids are upper-case letters, you can represent sets of amino-acids as ints. The set operations you need are then easily performed as bitwise and respectively or. Whenever you do a union operation, your costs increase by 1.

Another, more straight-forward solution is to calculate for each node of the tree the optimal costs for every amino acid the node can be marked with. This is done by trying every possible combination of amino acids for the two sub-trees, assuming their optimal costs have already been calculated. Since this solution might turn out to be too inefficient, it can be improved upon by observing that a father node always can be marked with either the left or the right son's amino-acid - there is no need to take an amino acid that differs from both.

Judges' test data was constructed from a test-case with a few long sequences, a test-case with many short sequences, a test-case where every possible pair of amino-acids occured, and 100 random-generated test-cases where length and number of sequences are geometrically distributed. The total number of test-cases is 110. Since there may be multiple correct answers for the test cases, a special verification program was written by slightly modifying the judges' solution.


 1 /* Accepted 1102 C++ 00:00.56 1040K */
 2 #include <string>
 3 #include <iostream>
 4 
 5 using namespace std;
 6 
 7 int main()
 8 {
 9     int n, l;
10     while((cin >> n >> l) && n && l)
11     {
12         int heap[2048], cost = 0;
13         string seq[1024];
14         
15         for(int i = 0; i < n; i++)
16             cin >> seq[i];
17         
18         for(int i = 0; i < l; i++)
19         {
20             for(int k = 0; k < n; k++)
21                 heap[n + k] = 1 << (seq[k][i] - 'A');
22             for(int k = n - 1; k >= 1; k--)
23                 if((heap[k] = heap[2 * k] & heap[2 * k + 1]) == 0)
24                 {
25                     cost++;
26                     heap[k] = heap[2 * k] | heap[2 * k + 1];
27                 }
28             char c = 'A';
29             while(heap[1>>= 1)
30                 c++;
31             cout << c;
32         }
33         cout << ' ' << cost << endl;
34     }
35     
36     return 0;
37 }
38 
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            久久免费视频在线| 久久精品最新地址| 欧美日韩亚洲视频一区| 99国内精品| 99伊人成综合| 国产精品亚洲激情| 久久夜色精品国产| 欧美h视频在线| 一本一本久久| 亚洲一二区在线| 国产专区综合网| 亚洲成人在线免费| 欧美综合77777色婷婷| 影音先锋一区| 亚洲黄色免费| 国产精品视频你懂的| 久久久999| 女仆av观看一区| 亚洲综合色丁香婷婷六月图片| 欧美一区二区三区在线免费观看| 永久免费视频成人| 亚洲激情第一区| 国产精品一区在线观看| 免费影视亚洲| 国产精品久久久久久久午夜| 久久综合伊人77777尤物| 欧美成年人网| 欧美一区二区三区在线| 麻豆成人在线播放| 亚洲小视频在线观看| 久久精品女人天堂| 这里只有精品丝袜| 久久精品一区二区三区中文字幕| aⅴ色国产欧美| 久久久久久日产精品| 国产精品99久久久久久有的能看| 欧美在线日韩精品| 9人人澡人人爽人人精品| 欧美在线观看网址综合| 一区二区三区 在线观看视| 亚洲影院色在线观看免费| 亚洲国产综合91精品麻豆| 亚洲尤物在线视频观看| 一本色道久久综合狠狠躁篇的优点 | 欧美a级片一区| 国产精品人人爽人人做我的可爱 | 亚洲无人区一区| 美女诱惑黄网站一区| 久久爱www.| 国产精品v日韩精品| 最近看过的日韩成人| 狠狠干综合网| 欧美一区二区视频在线| 亚洲永久网站| 欧美日韩一区二区三区四区在线观看 | 国内久久视频| 亚洲你懂的在线视频| 亚洲色图自拍| 欧美色播在线播放| 亚洲伦理中文字幕| 亚洲精品一区中文| 欧美多人爱爱视频网站| 免费成人在线观看视频| 黑人巨大精品欧美一区二区小视频 | 午夜精品久久久久久久| 亚洲欧美另类久久久精品2019| 欧美日韩不卡| 亚洲精品免费一二三区| 日韩亚洲视频在线| 欧美另类videos死尸| 亚洲黄页视频免费观看| 亚洲欧洲在线免费| 欧美成人中文| 亚洲开发第一视频在线播放| 一区二区三区欧美亚洲| 欧美午夜精品久久久久久久| 亚洲一区二区三区免费观看| 欧美一级久久| 激情综合五月天| 免费观看国产成人| 亚洲精品乱码久久久久久按摩观 | 亚洲精品美女91| 欧美大片在线看免费观看| 亚洲激情婷婷| 亚洲一区国产| 国产日韩欧美成人| 久久精品一区二区国产| 亚洲国产一区在线| 中文欧美日韩| 国产情人节一区| 久久影音先锋| 亚洲麻豆视频| 久久久亚洲精品一区二区三区 | 99re热这里只有精品视频| 欧美日韩国产bt| 午夜精品福利在线观看| 久久综合一区二区| 一本大道久久a久久综合婷婷| 国产精品高精视频免费| 久久国产精品久久w女人spa| 亚洲第一精品影视| 久久成人精品视频| 亚洲人成精品久久久久| 性欧美精品高清| 亚洲国内精品在线| 国产精品一区二区三区乱码| 久久精品国产视频| 亚洲免费av网站| 久久午夜电影网| 宅男在线国产精品| 永久免费精品影视网站| 国产精品久久久久久久免费软件 | 国外视频精品毛片| 欧美久久视频| 欧美亚洲网站| 亚洲精品免费网站| 牛牛国产精品| 久久国产精品亚洲77777| 999在线观看精品免费不卡网站| 国产精品欧美风情| 欧美aaa级| 久久久一区二区三区| 亚洲综合色视频| 夜夜夜久久久| 最新国产成人在线观看| 欧美 日韩 国产 一区| 久久国产精品免费一区| 亚洲一级在线观看| 日韩亚洲视频| 亚洲激情不卡| 亚洲激情第一区| 伊人男人综合视频网| 国产午夜精品一区二区三区欧美| 欧美午夜电影一区| 欧美日本网站| 欧美日韩国产综合视频在线| 欧美va日韩va| 蜜臀av国产精品久久久久| 欧美在线观看一区二区| 亚洲免费影视第一页| 亚洲午夜在线观看视频在线| 亚洲视频狠狠| 亚洲免费视频网站| 在线中文字幕一区| 一区二区欧美日韩| 99精品欧美一区| 日韩视频亚洲视频| 一区二区三区波多野结衣在线观看| 亚洲精品视频在线观看免费| 亚洲人成在线免费观看| 日韩视频亚洲视频| 中文精品视频| 羞羞色国产精品| 久久精品视频在线| 久热综合在线亚洲精品| 男人的天堂成人在线| 欧美国产高清| 欧美日韩在线播放三区四区| 国产精品久久福利| 国产精品一区久久| 狠狠色丁香久久婷婷综合丁香| 国内久久精品视频| 亚洲区一区二| 亚洲欧美精品suv| 久久久国产91| 欧美fxxxxxx另类| 亚洲精品日产精品乱码不卡| 一本一本久久a久久精品牛牛影视| 亚洲午夜在线观看视频在线| 欧美在线精品免播放器视频| 欧美91大片| 国产精品日韩欧美一区二区三区| 国产一区二区成人久久免费影院| 亚洲高清一二三区| 亚洲天堂免费观看| 久久久久国产精品厨房| 亚洲福利视频专区| 亚洲女同同性videoxma| 久久青青草综合| 欧美午夜精品理论片a级大开眼界| 国产一区二区| 亚洲午夜av电影| 麻豆精品一区二区av白丝在线| 99精品99久久久久久宅男| 久久精品99国产精品日本| 欧美激情视频免费观看| 国产麻豆视频精品| 99精品热视频只有精品10| 久久超碰97中文字幕| 亚洲人精品午夜在线观看| 欧美在线影院| 欧美性大战久久久久久久蜜臀| 在线观看不卡av| 午夜亚洲伦理| 亚洲区欧美区| 久久久av水蜜桃| 国产欧美在线观看| 一区二区三区视频观看| 欧美激情一区二区三区蜜桃视频| 午夜精品久久久|