Zoj 1076 Gene Assembly

Source: Internet
Author: User
Tags integer numbers

Gene Assembly Time limit: 2 Seconds Memory Limit: 65536 KB

Statement of the problem

With the large amount of genomic DNA sequence data being made available, it's becoming more important to find genes (p Arts of the genomic DNA which is responsible for the synthesis of proteins) in these sequences. It is known this for eukaryotes (in contrast to prokaryotes) The process is more complicated, because of the presence of J UNK DNA that interrupts the coding region of genes in the genomic sequence. That is, a gene was composed by several pieces (called exons) of coding regions. It is known that the order of the exons are maintained in the protein synthesis process, but the number of exons and their Lengths can arbitrary.

Most gene finding algorithms has a steps:in the first they search for possible exons; In the second they try to assemble a largest possible gene, by finding a chain with the largest possible number of exons. This chain must obey the order in which the exons appear in the genomic sequence. We say that exon I appears before exon J if the end of I precedes the beginning of J.

The objective of this problem are, given a set of possible exons, to find the chain with the largest possible number of Exo NS that Cound is assembled to generate a gene.

Input Format

Several input instances is given. Each instance begins with the number 0 < n < $ possible exons in the sequence. Then, each of the next n lines contains a pair of an integer numbers that represent the position in which the exon starts and Ends in the genomic sequence. You can suppose that the genomic sequence have at most 50000 basis. The input ends with a line with a single 0.

Output Format

For each input instance your program should print on one line the chain with the largest possible number of exons, by enum Erating the exons in the chain. If there is more than one chain with the same number of exons, your program can print anyone of them.

Sample Input

6
340 500
220 470
100 300
880 943
525 556
612 776
3
705 773
124 337
453 665
0

Sample Output

3 1 5) 6 4
2 3 1

Similar to the problem of the set, first sort, and then traverse to

1#include <iostream>2#include <cmath>3#include <cstdio>4#include <vector>5#include <list>6#include <string>7#include <cstring>8#include <cstdio>9#include <algorithm>Ten#include <Set> One  A using namespacestd; -  - structexon the { -     intstart, end; -     intindex; - }; +  - BOOLcmpConstexon& E1,Constexon&E2) + { A     if(E1.start = =E2.start) at         returnE1.end <E2.end; -      -     returnE1.start <E2.start; - } -  - intMain () in { -     intN; to      +      while(Cin >> N &&N) -     { theVector<exon>Vec; *          for(inti =0; I < n; ++i) $         {Panax Notoginseng exon exon; -CIN >> Exon.start >>Exon.end; theExon.index = i +1; + Vec.push_back (exon); A         } the sort (Vec.begin (), Vec.end (), CMP); +  -vector<int> chains[1005]; $         intChainsnum =0; $         intlen[1005], end[1005]; -memset (Len,0,1005*sizeof(int)); -  the          for(inti =0; I < vec.size (); ++i) -         {WuyiExon exon =Vec[i]; the  -             intj =0; Wu              for(; J < Chainsnum; J + +) -             { About                 if(End[j] <=Exon.start) $                 { -END[J] =Exon.end; - Chains[j].push_back (exon.index); -                 } A             } +             if(J = =chainsnum) the             { - Chains[chainsnum].push_back (exon.index); $End[chainsnum] =Exon.end; the++Chainsnum; the             } the         } the  -         intMaxindex, max =0; in          for(inti =0; I < chainsnum;i++) the         { the             if(Chains[i].size () >max) About             { theMax =chains[i].size (); theMaxindex =i; the             } +         } -  the          for(inti =0; I < chains[maxindex].size ()-1; i++)Bayi         { thecout << Chains[maxindex][i] <<" "; the         } -cout << chains[maxindex].back () <<Endl; -     } the}

Zoj 1076 Gene Assembly

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.