Description

The Genographic Project is a research partnership between IBM and The National Geographic Society that is analyzing DNA from hundreds of thousands of contributors to map how the Earth was populated.

As an IBM researcher, you have been tasked with writing a program that will find commonalities amongst given snippets of DNA that can be 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 are found in the molecule. There are 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 will begin with a line containing a single integer n indicating the number of datasets. Each dataset consists of the following components:

  • A single positive integer m (2 <= m <= 10) indicating the number of base sequences in this dataset.
  • m lines each containing a single base sequence consisting of 60 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" instead. If multiple subsequences of the same longest length exist, output only the subsequence that comes first in alphabetical order.

Sample Input

3
2
GATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
3
GATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATA
GATACTAGATACTAGATACTAGATACTAAAGGAAAGGGAAAAGGGGAAAAAGGGGGAAAA
GATACCAGATACCAGATACCAGATACCAAAGGAAAGGGAAAAGGGGAAAAAGGGGGAAAA
3
CATCATCATCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
ACATCATCATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AACATCATCATTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT

Sample Output

no significant commonalities
AGATAC
CATCATCAT

Hint

 
题目大意:找公共子串  长度优先 长度相等,字典序小的优先
觉得这题爆搜神的最有爱了
代码

 #include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
using namespace std;
int main()
{
char s[][],p[],q[];
int m,n,i,j,k,len;
scanf("%d",&m);
while(m--)
{
q[]='\0';
scanf("%d",&n);
getchar();
for(i=; i<n; i++)
scanf("%s",s[i]);//输入不解释
len=strlen(s[]);
for(i=; i<len; i++ )
{
for(j=len-i; j>; j--)
{
strncpy(p,s[]+i,j);
p[j]='\0';
for(k=; k<n; k++)
if(strstr(s[k],p)==NULL)
break;
if(k==n)
{
if(strlen(p)==strlen(q)&&strcmp(p,q)<)//字符串分段复制函数
strcpy(q,p);
if(strlen(p)>strlen(q))
strcpy(q,p);
}
}
}
if(strlen(q)>)
puts(q);
else
puts("no significant commonalities");
}
return ;
}

Blue Jeans的更多相关文章

  1. poj 3080 Blue Jeans

    点击打开链接 Blue Jeans Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10243   Accepted: 434 ...

  2. POJ3080——Blue Jeans(暴力+字符串匹配)

    Blue Jeans DescriptionThe Genographic Project is a research partnership between IBM and The National ...

  3. POJ 3080 Blue Jeans (字符串处理暴力枚举)

    Blue Jeans  Time Limit: 1000MS        Memory Limit: 65536K Total Submissions: 21078        Accepted: ...

  4. POJ 3080 Blue Jeans(Java暴力)

    Blue Jeans [题目链接]Blue Jeans [题目类型]Java暴力 &题意: 就是求k个长度为60的字符串的最长连续公共子串,2<=k<=10 规定: 1. 最长公共 ...

  5. poj3080 Blue Jeans【KMP】【暴力】

    Blue Jeans Time Limit: 1000MS   Memory Limit: 65536K Total Submissions:21746   Accepted: 9653 Descri ...

  6. (字符串 KMP)Blue Jeans -- POJ -- 3080:

    链接: http://poj.org/problem?id=3080 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88230#probl ...

  7. POJ 3080 Blue Jeans 找最长公共子串(暴力模拟+KMP匹配)

    Blue Jeans Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20966   Accepted: 9279 Descr ...

  8. POJ Blue Jeans [枚举+KMP]

    传送门 F - Blue Jeans Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u ...

  9. POJ3080 Blue Jeans —— 暴力枚举 + KMP / strstr()

    题目链接:https://vjudge.net/problem/POJ-3080 Blue Jeans Time Limit: 1000MS   Memory Limit: 65536K Total ...

  10. POJ 3080 Blue Jeans (求最长公共字符串)

    POJ 3080 Blue Jeans (求最长公共字符串) Description The Genographic Project is a research partnership between ...

随机推荐

  1. malloc 与 free 图

  2. poj3348 Cows 凸包+多边形面积 水题

    /* poj3348 Cows 凸包+多边形面积 水题 floor向下取整,返回的是double */ #include<stdio.h> #include<math.h> # ...

  3. javascript中涉及到汉字的比较

    在使用js中的"=="进行字符串的比较时,发现在英文情况下是ok的,但在中文比较时则不行了. 在网上搜索,提供了一个解决方法,使用 stringObject.localeCompa ...

  4. iOS--NSAttributedString使用介绍

    iOS–NSAttributedString使用介绍 原文见: http://www.itnose.net/detail/6177538.html http://***/html/topnews201 ...

  5. [iOS 开发]UITableView第一行显示不完全

    造成这个问题的原因可能有两个: 1. UITableView的contentOffset属性的改变: 2. MJRefresh调用两次headerEndRefreshing会造成刷新后UITableV ...

  6. sizeToFit的用法和用途

    最近有遇到过sizeToFit的方法,比较好奇,所以查了点资料 在官方文档中 - (void)sizeToFit; // calls sizeThatFits: with current view b ...

  7. 使用soapUI代替WSDL2JAVA生成cxf HTTPS 客户端调用代码

    如果直接用cxf下面的wsdl2java生成https服务调用代码,会报https证书的错误.在你不想导入证书的情况下,可以使用soapUI进行客户端代码的生成,步骤如下: 1.设置CXF,如下图: ...

  8. hdoj 2049 错排

    代码: #include <stdio.h> int main(){ int n,a,b,i,j; __int64 s[22],h[22]; s[1]=0; s[2]=1; s[3]=2; ...

  9. ExtJs 第二章,Ext.form.Basic表单操作

    1.认识Ext.form.Panel表单面板         Ext.form.field.CheckBox 复选框 checkboxfield Ext.form.CheckBoxGroup 复选框组 ...

  10. 中级Perl第二章习题

    2. 4. 1. 习题1 [15 分钟] 写一个程序从命令行取一个文件清单, 然后用grep 把那些文件大小在1000 字节以内的文件找出来.用map 把这个清单里的每个字串前加四个空格并在 字串后面 ...