POJ 3080 Blue Jeans

Source: Internet
Author: User

Topic Connection

http://poj.org/problem?id=3080

Blue jeansdescription

The Genographic Project is a-partnership between IBM and the National Geographic Society that's analyzing DNA fr Om Hundreds of thousands of contributors to map how the Earth was populated.

As an IBM researcher, you had been tasked with writing a program that would find commonalities amongst given snippets of D NA that can is correlated with individual survey information to identify new genetic markers.

A DNA Base sequence is noted by listing the nitrogen bases in the order in which they was found in the molecule. There is four bases:adenine (A), thymine (T), guanine (G), and cytosine (C). A 6-base DNA sequence could be represented as TAGACC.

Given a set of DNA base sequences, determine the longest series of bases that occurs in all of the sequences.

Input

Input to this problem would begin with a line containing a single integer n indicating the number of datasets. Each dataset consists of the following components:

    • A single Positive An integer m (2 <= m <=) indicating the number of the base sequences in this DataSet.
    • M lines each containing a single base sequence consisting of bases.
Output

For each dataset in the input, output the longest base subsequence common to all of the given base sequences. If the longest common subsequence is less than three bases in length, display the string "no significant commonalities" in Stead. If multiple subsequences of the same longest length exist, output only the subsequence that comes first in alphabetical or Der.

Sample Input

3
2
Gataccagataccagataccagataccagataccagataccagataccagataccagata
Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
3
Gataccagataccagataccagataccagataccagataccagataccagataccagata
Gatactagatactagatactagatactaaaggaaagggaaaaggggaaaaagggggaaaa
Gataccagataccagataccagataccaaaggaaagggaaaaggggaaaaagggggaaaa
3
Catcatcatccccccccccccccccccccccccccccccccccccccccccccccccccc
Acatcatcataaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Aacatcatcatttttttttttttttttttttttttttttttttttttttttttttttttt

Sample Output

No significant commonalities
Agatac
Catcatcat

String-Violence enumeration:

#include <algorithm> #include <iostream> #include <cstdlib> #include <cstring> #include < cstdio> #include <vector> #include <map>using std::map;using std::min;using std::find;using std::p air; Using std::vector;using std::multimap; #define PB (E) push_back (e) #define SZ (c) (int) (c). Size () #define MP (A, b) make_pair (A, B) #define ALL (c) (c). Begin (), (c). End () #define ITER (c) __typeof ((c). Begin ()) #define CLS (arr, Val) memset (arr, Val, si Zeof (arr)) #define Cpresent (C, E) (Find (All (c), (e))! = (c). End ()) #define REP (i, n) for (int i = 0; i < (int) n; i++) #defi NE tr (c, I) for (ITER (c) i = (c). Begin (); I! = (c). end (); ++i) const int N = 61;typedef char word[61];    Word str1, str2, st[11];void solve (int n) {bool F;    int I, j, k, len = 0;  for (i = 0; i < N-3; i++) {for (j = 3; J < N-i; J + +) {strncpy (str1, st[0] + i, j); Str1[j] =            ' N ';            F = true; for (k = 1; k < n; k++) {if (!strstr (St[k], str1)) {F= false; Break                }} if (f && J > Len) {len = j;            strcpy (str2, str1);            } if (f && j = len) {if (strcmp (str1, str2) < 0) strcpy (str2, str1); }}} puts (!len? "No significant commonalities": STR2);}    int main () {#ifdef LOCAL freopen ("In.txt", "R", stdin);    Freopen ("OUT.txt", "w+", stdout); #endif int t, n;    scanf ("%d", &t);        while (t--) {scanf ("%d", &n);        Rep (i, N) scanf ("%s", St[i]);    Solve (n); } return 0;}

Poj 3080 Blue Jeans

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.