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

superman

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

ZOJ 1102 - Phylogenetic Trees Inherited

Posted on 2008-04-06 11:13 superman 閱讀(440) 評論(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>
            久久久免费观看视频| 在线视频精品一区| 久久在线免费观看| 欧美有码在线视频| 狠狠色噜噜狠狠色综合久| 久久综合99re88久久爱| 久久久久久久999精品视频| 国产亚洲欧美日韩日本| 久久综合久色欧美综合狠狠| 久久精品亚洲精品| 亚洲全部视频| 一区二区国产精品| 国产亚洲激情在线| 欧美福利网址| 欧美性大战久久久久久久| 亚洲欧美高清| 久久精品视频播放| 日韩一级黄色大片| 午夜精品一区二区三区在线播放| 国产在线观看精品一区二区三区| 免费高清在线一区| 欧美日韩一区二区精品| 欧美一区二区三区啪啪| 鲁大师影院一区二区三区| 99精品久久久| 欧美一区二区视频免费观看| 亚洲国产天堂久久综合网| 一二三区精品福利视频| 狠狠综合久久av一区二区老牛| 欧美电影专区| 国产日本亚洲高清| 欧美激情国产日韩| 国产精品尤物| 亚洲精品一区二区三区婷婷月| 国产精品一区二区视频 | 国产精品久久久一本精品| 久久在线免费观看| 国产精品国产三级国产普通话三级| 久久久久国产一区二区三区| 欧美久久九九| 久久天天躁夜夜躁狠狠躁2022| 欧美高清在线| 噜噜爱69成人精品| 国产精品美女黄网| 亚洲免费观看高清完整版在线观看熊 | 亚洲一二三四久久| 亚洲精品国产精品国自产观看| 亚洲欧美综合v| 亚洲视频在线免费观看| 久久综合狠狠综合久久综合88| 午夜精品一区二区在线观看| 欧美黄色一区二区| 欧美大色视频| 精品成人一区二区三区| 午夜精品久久久久久99热| 一区二区三区免费网站| 欧美ed2k| 欧美电影在线免费观看网站 | 久久视频一区| 久久蜜臀精品av| 国产午夜精品福利 | 久久亚洲精品视频| 国产一区二区电影在线观看| 亚洲午夜精品久久久久久app| 亚洲精品色图| 欧美aⅴ一区二区三区视频| 欧美1区2区| 亚洲福利专区| 欧美77777| 最新成人av网站| 亚洲精选91| 欧美日韩国产一区二区三区| 亚洲欧洲另类| 99国产精品自拍| 欧美成人综合| 亚洲欧洲一区二区在线观看| 亚洲美女毛片| 欧美日韩国产三级| 一本色道久久综合亚洲精品婷婷| 亚洲视频在线观看视频| 国产精品久久午夜| 午夜国产精品视频| 久久亚洲一区二区三区四区| 在线观看国产精品淫| 麻豆精品视频在线观看| 最新中文字幕亚洲| 亚洲综合视频1区| 国产女主播一区二区三区| 欧美一区中文字幕| 亚洲大黄网站| 亚洲午夜在线视频| 国产亚洲综合精品| 免费亚洲视频| 中文一区二区在线观看| 久久国产精品久久久久久久久久| 国产在线不卡视频| 欧美黄色影院| 亚洲男同1069视频| 欧美aa国产视频| 中日韩高清电影网| 国产亚洲欧美日韩一区二区| 麻豆成人综合网| 亚洲视频欧美在线| 免费精品视频| 亚洲深夜激情| 在线观看不卡| 国产精品国产三级国产专播精品人 | 99日韩精品| 久久香蕉国产线看观看网| 99视频一区二区| 国产日产亚洲精品| 欧美精品一区二区三| 午夜欧美不卡精品aaaaa| 亚洲观看高清完整版在线观看| 亚洲欧美激情一区| 亚洲人成啪啪网站| 国产欧美一区二区三区国产幕精品| 巨乳诱惑日韩免费av| 亚洲专区在线视频| 亚洲免费观看视频| 欧美成人午夜影院| 久久久久久穴| 亚洲欧美一区二区视频| 日韩视频国产视频| 一区二区在线视频播放| 国产精品一区二区在线观看不卡| 欧美岛国激情| 久久久久一本一区二区青青蜜月| 亚洲香蕉伊综合在人在线视看| 最近看过的日韩成人| 免费在线成人av| 久久―日本道色综合久久| 亚洲资源在线观看| 国产精品99久久久久久白浆小说| 激情五月婷婷综合| 国产视频观看一区| 国产欧美一区二区三区久久| 欧美亚洲第一页| 欧美日韩性生活视频| 欧美久久久久| 欧美激情久久久| 欧美成人中文字幕在线| 欧美xxx成人| 欧美成人精品在线| 欧美成人首页| 欧美—级在线免费片| 欧美成人午夜剧场免费观看| 久久综合九色| 欧美大片在线观看一区| 女人香蕉久久**毛片精品| 免费精品视频| 欧美福利电影在线观看| 欧美激情一区二区三区蜜桃视频| 欧美大片在线看免费观看| 欧美成人tv| 欧美三级网页| 国产精品一区二区在线观看不卡| 国产精品免费看久久久香蕉| 国产精品影片在线观看| 国产一区视频在线观看免费| 国产揄拍国内精品对白| 国内精品久久久久久久影视麻豆 | 欧美午夜激情在线| 国产精品美女久久久久久2018 | 久久综合综合久久综合| 久久影视精品| 欧美日韩福利视频| 国产精品入口| 尤物在线精品| 一本综合精品| 久久高清一区| 亚洲第一区中文99精品| 亚洲视频播放| 久久精品成人| 欧美日本韩国| 国产伊人精品| 99视频在线精品国自产拍免费观看| 在线视频一区二区| 久久久国产精品一区| 亚洲国产欧美一区二区三区同亚洲| 一本色道久久| 久久精品日韩| 国产精品第2页| 136国产福利精品导航网址| 在线一区二区三区四区| 久久精彩免费视频| 亚洲人成欧美中文字幕| 欧美在线播放一区| 欧美日韩精品一区二区三区| 国产最新精品精品你懂的| 99视频日韩| 麻豆国产精品777777在线| 一区二区国产精品| 欧美99久久| 一区二区亚洲精品国产| 亚洲欧美国产毛片在线| 亚洲国产精品电影| 久久国产成人| 国产情侣久久| 亚洲在线一区|