POJ3080Blue Jeans(暴力)
开始做字符串专题,地址
第一题水题,暴力就可以做
- #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(暴力)的更多相关文章
- POJ-3080-Blue jeans(KMP, 暴力)
链接: https://vjudge.net/problem/POJ-3080#author=alexandleo 题意: 给你一些字符串,让你找出最长的公共子串. 思路: 暴力枚举第一个串的子串,挨 ...
- POJ3080——Blue Jeans(暴力+字符串匹配)
Blue Jeans DescriptionThe Genographic Project is a research partnership between IBM and The National ...
- POJ3080 Blue Jeans —— 暴力枚举 + KMP / strstr()
题目链接:https://vjudge.net/problem/POJ-3080 Blue Jeans Time Limit: 1000MS Memory Limit: 65536K Total ...
- POJ3080Blue Jeans
http://poj.org/problem?id=3080 题意 : 给你几个DNA序列,让你找他们的共同的最长的子串,若是子串长度小于3,就输出no significant commonaliti ...
- poj3080Blue Jeans(在m个串中找到这m个串的 最长连续公共子序列)
Description The Genographic Project is a research partnership between IBM and The National Geographi ...
- poj 3080 Blue Jeans (暴力枚举子串+kmp)
Description The Genographic Project is a research partnership between IBM and The National Geographi ...
- POJ 3080 Blue Jeans (字符串处理暴力枚举)
Blue Jeans Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 21078 Accepted: ...
- POJ 3080 Blue Jeans(Java暴力)
Blue Jeans [题目链接]Blue Jeans [题目类型]Java暴力 &题意: 就是求k个长度为60的字符串的最长连续公共子串,2<=k<=10 规定: 1. 最长公共 ...
- poj3080 Blue Jeans【KMP】【暴力】
Blue Jeans Time Limit: 1000MS Memory Limit: 65536K Total Submissions:21746 Accepted: 9653 Descri ...
随机推荐
- OpenStack(0) - Table of Contents
1. Keystone OpenStack Identity Service2. Starting OpenStack Image Service3. Starting OpenStack Compu ...
- PHP全栈工程师学习大纲
一.高性能网站开发功力提升 时间 标题 内容概要 2015-12-28 开学典礼以及工程师成长路线图 工程师成长的发展路径图.三个阶段,在各个阶段需要提升自己的地方,从技术上也讲了一些提高分析代码的工 ...
- 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境:2.搭建环境-2.2安装操作系统CentOS5.4
2.2. 安装操作系统CentOS5.4 两个虚拟机都安装,此步骤在创建虚拟机节点时: 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境所有链接: 1.资源 ...
- delphi7如何实现 科学计数的转换。 比如我输入2,触发之后会转换成2.000000E+00.求赐教
uses SysUtils; function StrToExp(s: string): string;var f: Extended;begin f := StrToFloat(s); Result ...
- 第二个UI脚本--Python+selenium之unittest+HTMLtestRunner及python的继承
前面有一篇对于常见元素的识别和操作的python自动化脚本,这一篇就接着聊下python的类继承,已经它的第三款unittest框架,和报告收集包HTMLtestRunner的应用. 还是直接上代码吧 ...
- 白盒测试之初识gtest工具
因为公司最近对软件产品质量提高了要求,之前项目组中黑盒测试方法就越来越无法满足公司的要求.虽然作为研发,但是也要求对白盒测试有一个系统的了解(毕竟之前没有系统的接触过白盒测试). 单元测试工具有很多种 ...
- 用Asp.net实现简单的文字水印
用Asp.net实现简单的文字水印 经常看见MOP上有人贴那种动态的图片,就是把一个字符串作为参数传给一个动态网页,就会生成一个带有这个字符串的图片,这个叫做文字水印.像什么原来的熊猫系列,还有后来 ...
- (转)log4j:WARN No appenders could be found for logger 解决方案
我们在使用Log4j的时候,总是出现: log4j:WARN No appenders could be found for logger (org.apache.ibatis.logging.Log ...
- Java的平台无关性
转载自:http://www.cnblogs.com/Y/archive/2011/03/22/JavaVM_Learning_Chapter2_Platform_Independence.html ...
- python测试api接口
在开发中,需要测试web-api的接口 spring mvc 使用单元测试非常方便,但是,受不了单元测试的启动速度.用python写了一个小脚本,用于测试接口, 测试脚本配置文件 api.yaml s ...