HDU - 2328 Corporate Identity

生物信息学名词解释 | K-mer (长度为k的短序列) K-mer 何谓K-mer 所谓Kmer,即为一段长度为k的DNA片段,是由测序reads剪切一部分得到的。k为一个奇数,k=几,就为几mer。 比如:我的测序reads长度为100bp,我将这100bp打断成17bp的短片段,打断后的17bp段片段就叫17mer,可以获得(100-17+1)条k-mer序列。 Table1 k-mers for GTAGAGCTGT. k k-mers 1 G,T,A,G,A,G,C,T,G,T 3 GTA,TAG,AGA,GAG,AGC,GCT,CT 阅读详情

Corporate Identity
Corporate Identity
Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4935 Accepted Submission(s): 1824

Problem Description
Beside other services, ACM helps companies to clearly state their “corporate identity”, which includes company logo but also other signs, like trademarks. One of such companies is Internet Building Masters (IBM), which has recently asked ACM for a help with their new identity. IBM do not want to change their existing logos and trademarks completely, because their customers are used to the old ones. Therefore, ACM will only change existing trademarks instead of creating new ones.

After several other proposals, it was decided to take all existing trademarks and find the longest common sequence of letters that is contained in all of them. This sequence will be graphically emphasized to form a new logo. Then, the old trademarks may still be used while showing the new identity.

Your task is to find such a sequence.

Input
The input contains several tasks. Each task begins with a line containing a positive integer N, the number of trademarks (2 ≤ N ≤ 4000). The number is followed by N lines, each containing one trademark. Trademarks will be composed only from lowercase letters, the length of each trademark will be at least 1 and at most 200 characters.

After the last trademark, the next task begins. The last task is followed by a line containing zero.

Output
For each task, output a single line containing the longest string contained as a substring in all trademarks. If there are several strings of the same length, print the one that is lexicographically smallest. If there is no such non-empty string, output the words “IDENTITY LOST” instead.

Sample Input
3
aabbaabb
abbababb
bbbbbabb
2
xyz
abc
0

Sample Output
abb
IDENTITY LOST

Source
CTU Open Contest 2007

Recommend
teddy

大致题意:给你n个字符串,求他们的最长公共字串。
思路:给任意一个字串,从长取到短,依次判断是否在其他字符串中出现过。

#include <iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>

using namespace std;
const int maxn = 4110;
int ne[maxn];

bool cmp(const string a, const string b)
{
    return a < b;
}

void GetNext(string p)
{   /*模式串的长度*/
	int pLen = p.size();
	ne[0] = -1;
	int k = -1;
	int j = 0;
	while(j < pLen)
	{
		if (k == -1 || p[j] == p[k])
		{
			++j;
			++k;
            ne[j] = k;
		}
		else
		{
			k = ne[k];
		}
	}
}

int KmpSearch(string s, string p)
{
	int i = 0;
	int j = 0;
	int sLen = s.size();
	int pLen = p.size();
	while (i < sLen && j < pLen)
	{
		if (j == -1 || s[i] == p[j])
		{
			i++;
			j++;
		}
		else
		{
			j = ne[j];
		}
	}
	if (j == pLen)
		return i - j;
	else
		return -1;
}

string s[maxn];
int main()
{
    int n;
    while(~scanf("%d", &n)){
        if(n == 0)break;
        for(int i = 0; i < n; i++){/*输入n个字符串*/
            cin>>s[i];
        }

        string answer = "";
        int len = s[0].size();
        int i;
        for(i = len; i >= 1; i--){
            for(int j = 0; j + i <= len; j++){
                string subs = s[0].substr(j, i);
//                cout<<subs<<endl;
                GetNext(subs);/*对当前模式串取next数组*/
                int k;
                for(k = 1; k < n; k++){
                    int ans = KmpSearch(s[k], subs);
                    if(ans == -1)break;
                }
                if(k == n)/*每个串都匹配*/
                {
//                    cout<<1<<endl;
                    if(answer.size() == 0)
                        answer = subs;
                    else
                        answer = min(answer, subs);
                }
            }
            if(answer.size() != 0)
                break;
        }
        if(answer.size() != 0)
            cout<<answer<<endl;
        else
            cout<<"IDENTITY LOST"<<endl;
    }
    return 0;
}
/*
3
aabbaabb
abbababb
bbbbbabb
2
xyz
abc
0
*/

『言善信』Fiddler工具 — 1、Fiddler介绍与安装 文章目录1、Fiddler简介2、Fiddler功能3、Fiddler工作原理4、Fiddler安装 1、Fiddler简介 Fiddler是强大的抓包工具之一,它能记录所有客户端和服务器之间的HTTP和HTTPS请求,是web调试的利器。 Fiddler是位于客户端和服务端之间的HTTP代理,它的原理是以web代理服务器的形式进行工作的,使用的代理地址是:127.0.0.1,端口默认为8888,我们也可以通过设置进行修改。 Fiddler可以抓取支持HTTP代理的任意程序的数据包,如果要抓取https会 阅读详情

相关推荐

hdu 2328 Corporate Identity(KMP)

题目链接:hdu 2328 Corporate Identity 题目大意:给出若干个串,求最长公共子串。 解题思路:和poj 3080一样的做法。 #include #include #include using namespace std; const int N = 4005; const int M = 205; int n, m, len, j

不慌不忙、不急不躁 1608

AEB(自动紧急制动)

AEB系统对静止物体的误判率受多种因素影响,包括传感器精度、算法复杂性以及环境条件等。通过多传感器融合、算法优化、硬件升级以及环境适应性增强等技术手段,可以有效减少误判问题。美国和欧洲的AEB法规均强调了技术性能和安全性,但具体要求有所不同。美国的NHTSA规定更注重高速和复杂场景下的紧急制动能力,而欧盟的ECE R152法规则更侧重于基础的AEB功能覆盖范围。

百态·数智思维 | 聚焦大数据、量化与未来AI 2562

HDU 2328 Corporate Identity

一直WA,后来陆陆续续发现一点小错误,说多了都是泪 这里最后查找有多少个串是满足条件的时候,用map先将r里每一个字符的位置(而不是其值,值会有很多重复的)映射为其所在的串,这样就不用自己去开个hash数组了 最后查找的时候用个set判断有多少个串满足条件 #include #include #include #include #include using namespace std; #

lj94093的专栏 683

【Linux系统】Kdenlive软件多机位同音频视频同步化处理

Kdenlive简介 官网链接:https://kdenlive.org/zh/ 命令行安装: apt-get install kdenlive Kdenlive能够进行多轨道视频编辑,可以使用和调整多条音频、视频轨道。每条轨道可以按需进行单独锁定、静音。 Kdenlive多机位同音频视频同步化处理步骤 1. 新建Kdenlive文件 选择<文件>-<新建>,建立新的kdenlive文件,初始设置为<视频轨:2>,<音频轨:2>。 视.

qq_31550269的博客 1897

Ubuntu22.04 网络图标消失与连接故障排查指南(附实战修复流程)

本文详细介绍了Ubuntu22.04系统中网络图标消失与连接故障的排查与修复方法。通过ifconfig、dhclient等命令诊断问题,提供从紧急恢复网络连接到深度排查的完整解决方案,帮助用户快速恢复网络功能并预防类似问题再次发生。

weixin_28481133的博客 306

hdu2328Corporate Identity

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2328 找一个字典序最小的公共最长子串,枚举子串暴力就能过,这里有个小优化就是选取最短的字符串枚举其子串。#include <stdio.h> #include<iostream> #include<cstring> #include<cstdlib> #include<cmath> using nam

IDrandom的专栏 712

Android Qcom USB Driver学习(五)

在前面的第二期中,我们知道一些非标的USB的充电类型Floatingcharger,其具有和普通DCP相似的大电流能力,但在最初检测的时候会限制Inputcurrentlimit到100mA,来进行检测是否是SDP类型,所以要支持大电流输入就需要进行vote操作,前面的几篇都有涉及,所以本文学习一下pmicusbcharger都相关的vote机制。...

Android驱动开发 2929

HDU - 2328 Corporate Identity(暴力截取)

HDU - 2328 Corporate Identity #include<iostream> using namespace std; const int N = 4010; string s[N]; int n; bool check(string str) { for(int i=2;i<=n;i++) if(s[i].find(str)==string::npos) return false; return true; } int main() { while(

00后的博客 349

微信小程序 - error_msg:net::ERR_CONNECTION_RESET“(“errno“:600001,“errMsg“:“uploadFile:fail errcode:-101)

"errno":600001,"errMsg":"uploadFile:fail errcode:-101 cronet_error_code:-101 error_msg:net::ERR_CONNECTION_RESET"微信小程序,微信小程序wx.uploadFile报错,uniapp微信小程序uni.uploadFile上传文件报错,微信小程序调用wx.uploadFile返回错误ERR_CONNECTION_RESET,如何解决这个问题,上传图片出现报错,小程序上传视频报错,上传文件出现报错,如何

🏆 前端领域优质创作者 5451

Python爬虫实战:使用最新技术抓取采购网招标公告信息

本文将详细介绍如何使用Python最新爬虫技术构建一个高效的采购网招标公告信息抓取系统。我们将从爬虫基础概念讲起,逐步深入到高级技巧,包括异步处理、反爬虫对策、数据解析与存储等,并提供完整的代码实现。本文旨在为读者提供一套完整的网络数据采集解决方案,适用于各类政府采购平台和商业招标网站。网络爬虫(Web Crawler)是一种自动抓取互联网信息的程序或脚本,它们按照一定的规则,自动地浏览万维网并提取所需数据。在现代商业环境中,爬虫技术广泛应用于价格监控、竞争情报收集、市场研究等领域。

2201_76125261的博客 1634

HDU 2328(Corporate Identity)

题意:给定 n 个字符串,求最大子串,使得它是 n 个字符串的子串。(若有多种答案,输出字典序最小的) 分析:每个字符串长度不超过200,则可以暴力枚举子串 然后 KMP。 代码: #include<cstdio> #include<cstring> #include<iostream> using namespace std; const...

Joker & Liar的博客 195

基于FFT+BP神经网络/决策树的轴承故障诊断

基于FFT+BP神经网络/决策树的轴承故障诊断

天天酷科研的博客 141

hdu 2328 Corporate Identity

输出最长公共子串 Corporate Identity Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 795    Accepted Submission(s): 318 Problem Descri

便纵有千种风情 623

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

HDU 2328 Corporate Identity 后缀数组

求多个字符串的最长公共子串,若有多个输出字典序最小。 先复习一下,(i,j)表示排名i、j的串的最长公共前缀。(i,j) = min[(i,i+1),(i+1,i+2),......,(j-1,j)]。 两个字符串的最长公共前缀求法: 将两个字符串合起来,中间加个特殊符号,然后对整个字符串求后缀数组。 扫描height数组,如果排名i和i+1的串分别属于不同的原始串,则用heigh

938

InTheHand.Net.Personal+BlueTooth4,蓝牙开发

项目中有蓝牙开发的必备dll,现在网上相关的文档博客不少,有的说的多有的说少,但是却很少有这两个dll,分享一下。

hdu 2328 Corporate Identity

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2328 题目大意:求多串的最长公共子串,并输出字典序最小。 题目思路:后缀数组,二分答案。 #include #include #include #include #include #include #include #include #include #include #include usin

Wings_of_Liberty的专栏 796

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

Corporate Identity HDU - 2328 (KMP)

Beside other services, ACM helps companies to clearly state their “corporate identity”, which includes company logo but also other signs, like trademarks. One of such companies is Internet Building M...

Top_Spirit的博客 343

HDU-2328 Corporate Identity

题目链接:https://vjudge.net/problem/HDU-2328 还是在多个字符串中寻找最长公共子串 从第一个字符串里找子串和其他字符串匹配,有多个最长的输出字典序最小的 #include #include #include #include #include using namespace std; const int N=200+10; //文本串长度 const in

wl16wzl的博客 341

【hdu 2328】Corporate Identity

【链接】h在这里写链接 【题意】 找一个字典序最小的公共最长子串; 【题解】 后缀数组。 把所有的串用不同的分隔符分开。(大于'z'的分隔符); 然后求出那几个固定的数组。 二分一下那个子串的长度. 看看是不是在N个串里面都有这个串即可。 可以用一个下标,来记录某个位置开始的后缀是第几个串里面的(即输入的N个串里面的哪一个串). 子串长度越大显然越不可能存在。 (因...

AWCXV 59

【kmp】Corporate Identity HDU - 2328

Think: 1知识点:kmp算法+暴力枚举 2题意:输入一组字符串,寻找最长公共子串,长度相同时选择字典序最小的 3解题思路: (1):找到字符串组中长度最短的字符串,然后根据左右区间枚举查询 (2):找到字符串组中长度最短的字符串,然后根据长度从大至小枚举,若在当前长度梯度已经找到串,则结束枚举(因为从大至小枚举的长度梯度级,因此下面枚举的长度梯度级要小于当前已经枚举完成的长度梯度级)

BlessingXRY的博客 455

HDU2328(Corporate Identity)

Corporate Identity Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4328 Accepted Submission(s): 1598 Problem Description Beside other servic...

Shaosen的博客 296

HDU-2328 Corporate Identity (暴力)

题意:和 POJ-3080 Blue Jeans 基本上一样:求n个串的公共子串,只是数据增大了(字符串长度) 完整代码: #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <cmath&gt...

166

HDU 2328 Corporate Identity kmp暴力

一、 内容 Beside other services, ACM helps companies to clearly state their “corporate identity”, which includes company logo but also other signs, like trademarks. One of such companies is Internet Buil...

Tizzi的博客 722

HDU2328 Corporate Identity

题目链接:HDU2328 Corporate Identity Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 968    Accepted Submission(s): 386 Problem Descri

teddywang 396

【ICPC-228】hdu 2328 Corporate Identity

点击打开链接hdu 2328 思路:kmp+暴力枚举子串 分析: 1 题意要求最长的公共子串,由于每一串的长度最长不超过200,所以可以选择暴力枚举最短的单词的子串来求出ans 2 利用kmp来匹配 代码: #include<iostream> #include<algorithm> #include<cstdio> #include<cst...

藏经阁 | 玄苦 1705

HDU - 2328 Corporate Identity(kmp)

题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=2328 题意 同 poj3080 https://blog.csdn.net/a670531899/article/details/81570063 思路 直接暴力,不过(200^3)*4000居然都能过?好神奇的数据。 代码 #include&lt;iostream&gt; #i...

a670531899的博客 228
上一篇: HDU - 1238SubStrings
下一篇: 牛客 NC16593 铺地毯
WA怪
博客等级 码龄8年 14粉丝 122原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值