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. 排序算法c语言描述---堆排序

    排序算法系列学习,主要描述冒泡排序,选择排序,直接插入排序,希尔排序,堆排序,归并排序,快速排序等排序进行分析. 文章规划: 一.通过自己对排序算法本身的理解,对每个方法写个小测试程序.具体思路分析不 ...

  2. 转自知乎,亲民好酒推荐 分类: fool_tree的笔记本 2014-11-08 17:37 652人阅读 评论(0) 收藏

    这里尽量为大家推荐一些符合大众喜好.业内公认好评."即使你不喜欢,你也会承认它不错"的酒款.而且介绍到的酒款还会有一个共同的特征,就是能让你方便的在网上买到. 大概会分为烈酒,利口 ...

  3. Swift学习笔记八:枚举

    1. 枚举语法      1)枚举的定义 使用enum关键词而且把它们的整个定义放在一对大括号内: enum SomeEumeration { // enumeration definition go ...

  4. 搜索框中“请输入搜索keyword”

    $(function(){    $("#ctl00_txtKey").val("请输入搜索keyword").addClass("search&qu ...

  5. android 18 Bundle类

    Bundle类:竖屏的activity换到横屏的activity的时候,会把竖屏的activity杀掉横屏的activity创建,竖屏的activity会有一些计算结果,可以用数据存起来,存到内存里面 ...

  6. AlgorithmVisualizer

    http://jasonpark.me/AlgorithmVisualizer/#path=graph_search/floyd_warshall/shortest_paths

  7. objective-c 中的关联介绍

    objective-c 中的关联介绍 转载请注明CSDN博客上的出处: http://blog.csdn.net/daiyibo123/article/details/46471993 如何设置关联 ...

  8. SpringSecurity 在MVC 中的简单使用(翻译的,稍加改动)

    Spring Security允许开发人员轻松地将安全功能集成到J2EE Web应用程序中,它通过Servlet过滤器实现“用户自定义”安全检查. 在本教程中,我们将向您展示如何在Spring MVC ...

  9. XFire中Services.xml 配置的一些细节

    昨天第一次调XFire引擎,放在Tomcat里之后老是报错,检查了很久没有发现什么问题,一直很费解. 后来在网上看到一篇文章<XFire services.xml 配置文件补充说明>,根绝 ...

  10. Asp.Net 注册 邮箱激活

    数据库 表的设计 State为用户状态  0为禁用  1为可用  默认为0,下面有个UserGUID,这个字段将来用于激活账户 首先你要写一个表单,验证码神马的,这个我就不写了..直接写处理的 代码在 ...