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

superman

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

ZOJ 1102 - Phylogenetic Trees Inherited

Posted on 2008-04-06 11:13 superman 閱讀(435) 評論(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>
            欧美日韩岛国| 久久综合九色欧美综合狠狠| 国产精品午夜春色av| 欧美伦理在线观看| 欧美激情一区二区久久久| 欧美黄在线观看| 欧美人交a欧美精品| 欧美日韩中文字幕日韩欧美| 国产精品电影观看| 久久久久久999| 久久九九精品| 亚洲国产欧美在线人成| 蜜臀久久久99精品久久久久久| 美女视频黄免费的久久| 亚洲电影免费观看高清完整版在线 | 国色天香一区二区| 亚洲第一精品福利| 一区二区三区欧美亚洲| 亚洲欧美一区二区精品久久久| 久久精品91| 久久理论片午夜琪琪电影网| 美女诱惑黄网站一区| 亚洲乱码国产乱码精品精98午夜| 一本一本大道香蕉久在线精品| 亚洲电影免费在线 | 欧美亚洲尤物久久| 麻豆精品一区二区av白丝在线| 欧美日韩国产页| 黄色日韩网站| 亚洲免费在线| 亚洲第一精品夜夜躁人人爽| 亚洲视频一二三| 免费在线亚洲| 国产日韩专区| 亚洲色无码播放| 欧美成人一区二区| 午夜电影亚洲| 欧美日韩一区在线| 亚洲国产裸拍裸体视频在线观看乱了中文| 一区二区高清在线观看| 久色成人在线| 亚洲欧美日韩国产一区二区| 免费成人激情视频| 国内精品美女av在线播放| 亚洲无线观看| 亚洲伦理久久| 欧美精品国产精品日韩精品| 在线观看成人av| 久久精品2019中文字幕| 日韩亚洲欧美中文三级| 欧美大学生性色视频| 极品少妇一区二区三区| 久久久久久夜| 欧美亚洲日本一区| 亚洲精品视频在线观看免费| 久久国产精品久久久久久久久久| 国产精品美女久久久| 亚洲视频在线观看视频| 亚洲精品在线二区| 欧美日韩你懂的| 亚洲天堂网在线观看| 亚洲美女视频网| 欧美日韩国产经典色站一区二区三区| 亚洲欧洲在线观看| 亚洲国产精品成人综合| 免费久久久一本精品久久区| 在线精品视频一区二区| 欧美成人小视频| 欧美成人激情在线| 日韩视频一区二区在线观看 | 国产日韩欧美成人| 欧美激情精品久久久久久大尺度 | 女女同性女同一区二区三区91| 国产一区二区三区四区在线观看 | 亚洲毛片av在线| 欧美日韩亚洲天堂| 亚洲午夜久久久久久尤物 | 久久精品国产精品亚洲精品| 欧美亚洲综合网| 狠狠久久婷婷| 亚洲大胆人体视频| 欧美另类专区| 亚洲欧美综合v| 欧美一区二区三区在线播放| 含羞草久久爱69一区| 欧美成人综合一区| 欧美日韩精品三区| 久久国产精品99国产精| 久久精品国产亚洲精品 | 怡红院精品视频| 亚洲欧洲日产国产网站| 欧美亚洲第一页| 美日韩精品视频免费看| 欧美福利在线| 欧美一区二区三区免费视| 欧美在线1区| 一区二区三区欧美在线| 午夜日韩电影| 欧美亚洲视频在线观看| 伊人久久综合| 亚洲视频精选在线| 亚洲电影免费观看高清完整版在线| 亚洲精华国产欧美| 国产视频在线一区二区| 亚洲人精品午夜| 国产亚洲一区二区三区在线观看| 亚洲国产精品va在线看黑人 | 亚洲区国产区| 午夜精品久久久久久久99水蜜桃| 亚洲国产导航| 亚洲欧美在线磁力| 日韩亚洲一区在线播放| 久久激情五月婷婷| 亚洲欧美日韩另类| 欧美黑人在线观看| 久久亚洲综合色| 国产精品久久久久久久午夜片| 老鸭窝亚洲一区二区三区| 欧美午夜不卡视频| 亚洲激情网站| 亚洲国产精品v| 久久久久国产精品一区| 午夜精品久久久久| 欧美日韩精品欧美日韩精品| 欧美大片免费看| 尤物yw午夜国产精品视频| 亚欧成人在线| 免费成人av| 亚洲最快最全在线视频| 国产情人综合久久777777| 99天天综合性| 亚洲美女福利视频网站| 久久亚洲精品中文字幕冲田杏梨| 久久疯狂做爰流白浆xx| 国产精品九色蝌蚪自拍| 亚洲免费久久| 99re热这里只有精品免费视频| 久久人人超碰| 免费在线欧美黄色| 在线播放中文字幕一区| 久久久91精品国产一区二区三区 | 亚洲欧洲99久久| 欧美在线观看视频在线| 国产精品夜夜夜| 午夜欧美大尺度福利影院在线看 | 亚洲欧美999| 国产精品热久久久久夜色精品三区| 亚洲美女在线看| 亚洲专区一二三| 国产精品每日更新| 欧美一级淫片播放口| 久久婷婷国产综合尤物精品| 99riav久久精品riav| 亚洲一本视频| 国产精品美女主播| 欧美一区二区高清在线观看| 久久久www免费人成黑人精品| 国产综合色精品一区二区三区| 久久精品国产一区二区三区免费看| 免费日韩精品中文字幕视频在线| 在线看一区二区| 欧美日本韩国| 亚洲婷婷综合久久一本伊一区| 欧美一区二区三区免费大片| 亚洲成色777777在线观看影院| 欧美国产日韩精品| 国产精品99久久久久久久vr | 欧美另类在线播放| 午夜精品成人在线| 免费在线日韩av| 一本一道久久综合狠狠老精东影业 | 久久久夜精品| 亚洲电影在线观看| 欧美视频在线观看一区二区| 亚洲欧美成人一区二区在线电影 | 亚洲天堂av在线免费观看| 久久久免费观看视频| 亚洲精品影院在线观看| 国产精品美女久久久久久免费| 久久久免费精品视频| 夜夜嗨av一区二区三区中文字幕| 久久久精品999| 一本久道久久久| 欲色影视综合吧| 一区二区三区久久精品| 宅男精品视频| 国产一区二区三区四区| 欧美久久99| 久久久久久久成人| 中文精品视频| 最新国产拍偷乱拍精品 | 欧美国产欧美亚洲国产日韩mv天天看完整 | 亚洲一区在线免费| 亚洲国产日韩一级| 久久免费黄色| 欧美日韩国产一区精品一区| 欧美在线观看你懂的| 一区二区毛片| 亚洲日韩中文字幕在线播放| 美女视频黄 久久|