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. [RxJS] Filtering operator: filter

    This lesson introduces filter: an operator that allows us to let only certain events pass, while ign ...

  2. Android开发实例-健康食谱应用(一)

    转载请注明出处:http://blog.csdn.net/einarzhang/article/details/44774635 本系列文章的重点是如何使用Android开发一个简单的健康食谱软件.使 ...

  3. Qt绘图之QGraphicsScene QGraphicsView QGraphicsItem详解

    Graphics View提供了一个界面,它既可以管理大数量的定制2D graphical items,又可与它们交互,有一个view widget可以把这些项绘制出来,并支持旋转与缩放.这个柜架也包 ...

  4. htmlentities() 函数

    Definition and Usage定义和用法 The htmlentities() function converts characters to HTML entities.htmlentit ...

  5. C#开发学习——内联表达式

    <%@ 表示:引用 <%# 表示:绑定 <%= 表示:取值     <%= 变量名%> Response.Write()输出和<%=%>输出最后的效果是一样的 ...

  6. C# 内存管理优化畅想(三)---- 其他方法&结语

    前两篇文章提出的优化方法,都是不需要修改源代码的,而是在CLR或JIT层面进行自动优化的.但本文中提出的优化方法则需要引入新的语法,开发者只有在源代码中使用了这些新语法,才会获得优化. 1. 允许对象 ...

  7. android 利用隐式Intent打开图片

    实现功能   点击"查看图片"时能够跳出提示,选择系统图库打开还是自己编写的应用打开,并且对于下载好的图片也有效. 1.我将 qiaoba.jpg 放在 res/drawable  ...

  8. Eclipse代码自动填充.

    在默认情况下,Eclipse只在程序员输入“.”并用ALT+/组合键强制调用编码提示功能 我们可以通过少量配置,让Eclipse更聪明,实现完全自动编码提示:1.在你的“工作空间”下找到下在文件.me ...

  9. AFNETWORKING tabelView没有reloadData,报错unsupported URL

    Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL" UserInfo=0x7f9dc278aa60 {NSUnde ...

  10. spring-quartz普通任务与可传参任务

    两者区别与作用: 普通任务:总调度(SchedulerFactoryBean)--> 定时调度器(CronTriggerFactoryBean) --> 调度明细自定义执行方法bean(M ...