开始做字符串专题,地址

第一题水题,暴力就可以做

 #include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define inf (-((LL)1<<40))
#define lson k<<1, L, mid
#define rson k<<1|1, mid+1, R
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define mem(a, b) memset(a, b, sizeof(a))
#define FOPENIN(IN) freopen(IN, "r", stdin)
#define FOPENOUT(OUT) freopen(OUT, "w", stdout) template<class T> T CMP_MIN(T a, T b) { return a < b; }
template<class T> T CMP_MAX(T a, T b) { return a > b; }
template<class T> T MAX(T a, T b) { return a > b ? a : b; }
template<class T> T MIN(T a, T b) { return a < b ? a : b; }
template<class T> T GCD(T a, T b) { return b ? GCD(b, a%b) : a; }
template<class T> T LCM(T a, T b) { return a / GCD(a,b) * b; } //typedef __int64 LL;
typedef long long LL;
const int MAXN = ;
const int MAXM = ;
const double eps = 1e-; char str[][], ansStr[];
int T, N; int maxLen(char* s1, char* s2)
{
int ans = ;
for(int i=;s2[i];i++)
{
int len = ;
for(int j=;s1[j];j++)
{
if(s2[i+j] == s1[j]) len++;
else break;
}
ans = max(ans, len);
}
return ans;
} int main()
{
while(~scanf("%d", &T))while(T--)
{
mem0(str); mem0(ansStr);
scanf("%d%*c", &N);
for(int i=;i<N;i++) scanf("%s", str[i]);
int ans = ;
for(int i=;str[][i];i++)
{
int len = INF;
for(int j=;j<N;j++)
{
len = min( len, maxLen(&str[][i], str[j]) );
}
if(ans < len)
{
ans = len;
for(int j=i;j<i+ans;j++) ansStr[j-i] = str[][j];
ansStr[i+ans] = ;
}
else if(ans == len)
{
int ok = ;
for(int j=;j<ans;j++)
{
if(ok) ansStr[j] = str[][i+j];
else if(ansStr[j] != str[][i+j])
{
if(ansStr[j] < str[][i+j]) break;
else { ansStr[j] = str[][i+j]; ok = ; }
}
}
}
}
if(ans >= )
printf("%s\n", ansStr );
else printf("no significant commonalities\n");
}
return ;
}

POJ3080Blue Jeans(暴力)的更多相关文章

  1. POJ-3080-Blue jeans(KMP, 暴力)

    链接: https://vjudge.net/problem/POJ-3080#author=alexandleo 题意: 给你一些字符串,让你找出最长的公共子串. 思路: 暴力枚举第一个串的子串,挨 ...

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

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

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

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

  4. POJ3080Blue Jeans

    http://poj.org/problem?id=3080 题意 : 给你几个DNA序列,让你找他们的共同的最长的子串,若是子串长度小于3,就输出no significant commonaliti ...

  5. poj3080Blue Jeans(在m个串中找到这m个串的 最长连续公共子序列)

    Description The Genographic Project is a research partnership between IBM and The National Geographi ...

  6. poj 3080 Blue Jeans (暴力枚举子串+kmp)

    Description The Genographic Project is a research partnership between IBM and The National Geographi ...

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

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

  8. POJ 3080 Blue Jeans(Java暴力)

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

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

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

随机推荐

  1. 07_js走路小游戏

    <html> <head> <!-- 不做了,思路: 按enter键停止,将xs,ys替换为0,再次按,判断xs和ys是否为0,是的话,讲根据fx给xsys赋值. 实现鼠 ...

  2. IOS中(类似于进度条哪种效果)MBProgressHUD的使用

    1.显示HUD MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; hud.labelText = ...

  3. mac出现一个白条

    mac出现一个白条,除了finder没有任何程序运行,出现好几次了,怎么解决? 打开finder输中文出现 按esc键

  4. 【自动化测试】Selenium - 定位

    http://easonhan007.github.io/selenium/2014/01/10/se-secret_01/ 你应该遵照这个规则来选择定位元素的属性.name > id > ...

  5. LOL-无双剑姬我的最爱

    LOL打了几年了,是一种娱乐的好方式,但是一个人玩不开黑就很无聊.这游戏最开始我玩的时候无论是赢是输就无所谓的,很高兴的.但是现在输了反而很气愤.也不知道为什么,所以很少玩了. 剑姬对反甲:如果对方出 ...

  6. Java中ThreadLocal的深入理解

    官方对ThreadLocal的描述: "该类提供了线程局部(thread-local)变量.这些变量不同于它们的普通对应物,因为访问某个变量(通过其get或set方法)的每个线程都有自己的局 ...

  7. Android的两种上下文的区别

    1.Activity.this,Activity是间接继承自Context 2.getApplicationContext()返回来的就是Context 3.getBaseContext()返回的也是 ...

  8. ECSide标签属性说明之<ec:table>

    <ec:table>标签说明 ◆ 属性: tableId描述: 设置列表的唯一标识,默认为"ec",当一个页面内有多个ECSIDE列表时,必须为每个列表指定不同的tab ...

  9. web-ylbtech-数据库备份-数据库设计

    ylbtech-DatabaseDesgin:web-ylbtech-数据库备份-数据库设计 DatabaseName:ylbtech Model:备份 Type:数据库备份设计 Url: 1.A,数 ...

  10. mybatis系列-15-查询缓存

    15.1     什么是查询缓存 mybatis提供查询缓存,用于减轻数据压力,提高数据库性能. mybaits提供一级缓存,和二级缓存. 一级缓存是SqlSession级别的缓存.在操作数据库时需要 ...