POJ 3450 Corporate Identity 求所有字符的最长公共子串

若依框架整合Flowable:从零构建企业级流程中心 本文详细介绍了如何将若依框架与Flowable工作流引擎整合,构建企业级流程中心。通过环境配置、依赖添加、数据库设置等核心步骤,实现流程定义管理、任务处理服务等关键功能,并结合实际案例展示请假审批流程的实现与动态表单集成。文章还提供了性能优化和生产建议,帮助开发者高效构建稳定可靠的工作流系统。 阅读详情

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


题意很长,其实就是求一组字符串的最长公共子字符串。

利用KMP可以在O(N)时间内查找一个字符串在另外一个字符串的最长前缀子字符串的特点加速程序。

#include <stdio.h>
#include <string.h>

const int MAX_N = 4001;
const int MAX_L = 201;
char sameStr[MAX_L], dict[MAX_N][MAX_L];
int nxTbl[MAX_L];
int len[MAX_N];

template<typename T1, typename T2>
inline bool equ(T1 t1, T2 t2) { return (T1)t1 == (T1)t2; }

void getNextTble(int *t, char *s, int len)
{
	t[0] = 0;
	for (int i = 1, j = 0; i < len; )//j 记录最后一个好前缀的下标
	{
		if (s[i] == s[j]) t[i++] = ++j;//++j等于有多少个好前缀
		else if (j > 0) j = t[j-1];//取得下一个对比字符的下标
		else t[i++] = 0;
	}
}

int getLongestPre(char *chs, char *s, int len1, int len2)
{
	int len3 = 0;
	int i = 0, j = 0;
	for (; i < len2 && j < len1; )
	{
		if (equ(s[i], chs[j]))
		{
			i++, j++;
			if (j > len3) len3 = j;
		}
		else if (j > 0) j = nxTbl[j-1];
		else i++;
	}
	return len3;
}

bool smaller(char *s1, char *s2, int L)//lexicographically smaller
{
	for (int i = 0; i < L; i++)
	{
		if (s1[i] < s2[i]) return true;
		else if (s1[i] > s2[i]) return false;
	}
	return false;
}

int main()
{
	int N;
	while (~scanf("%d\n", &N) && N)
	{
		for (int i = 0; i < N; i++)
		{
			gets(dict[i]);
			len[i] = strlen(dict[i]);
		}
		char *p = dict[0];
		char *pRes = NULL;
		int L = 0;
		for (; len[0]; len[0]--, p++)
		{
			getNextTble(nxTbl, p, len[0]);
			int tmp = len[0];
			for (int i = 1; i < N && tmp; i++)
			{
				tmp = getLongestPre(p, dict[i], tmp, len[i]);		
			}
			if (tmp > L || equ(tmp, L) && smaller(p, pRes, L))
			{
				L = tmp;
				pRes = p;
			}
		}

		if (L)
		{
			for (int i = 0; i < L; i++) putchar(pRes[i]);
			putchar('\n');
		}
		else puts("IDENTITY LOST");
	}
	return 0;
}




荔枝派Nano内核编译 上文编译好uboot之后,想刷内核和根文件系统进去。其实官方的网盘里面,已经有打包好的系统镜像,包含所有的东西,可以直接烧录进flash或者TF卡,但是都是基于winbond芯片的,国产的xt25f128b刷进去妥妥的。所以没办法,只能自己再动手重新编译内核了。(PS:搞的我都想直接买一片w25q128换上了,有点麻烦,希望官方直接涨价或者出两版就行,不然对新手不友好啊) 阅读详情

相关推荐

迈德威视相机调用( 基于 Linux系统+ OpenCV )

迈德威视相机调用( 基于 Linux系统+ OpenCV )前言一、登录迈德威视官网,下载官方SDK二、代码调用与视频帧处理( 基于 OpenCV )总结 前言     此博客记录了迈德威视工业相机在 Linux 系统下的代码调用及其环境配置,通过 OpenCV 对视频帧进行处理。   一、登录迈德威视官网,下载官方SDK      迈德威视官网 : http://www.mindvision.com.cn/     1. 进入官网后,在服务支持中选择软件下载。    2. 选择Linux系统S.

kkkkkk0729的博客 5693

HDU - 2328——Corporate Identity (多串找公共字串)

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 Ma...

creator平 405

告别环境依赖!用PyInstaller把PaddleOCR项目打包成独立EXE(附完整spec文件配置)

本文详细介绍了如何使用PyInstaller将PaddleOCR项目打包成独立EXE文件,彻底解决Python环境依赖问题。通过完整的spec文件配置和实战技巧,开发者可以轻松创建开箱即用的OCR工具,特别适合需要交付给非技术用户的场景。文章涵盖环境配置、模型打包、性能优化等关键环节,并提供了解决常见问题的方案。

weixin_33712987的博客 582

poj3450之kmp入门

Corporate Identity Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 4087   Accepted: 1547 Description Beside other services, ACM helps companies to clearly

Stephen 1080

python使用TensorRT报错,多线程或多进程中使用问题

python使用TensorRT报错,Cuda Runtime问题

qq_44224801的博客 756

计算机视觉——多视图几何

多视图几何1.前言1.1 多视图几何概念2. 基本原理2.1 对极几何2.2 基础矩阵2.2.1 基础矩阵推导2.2.2 求解基础矩阵3. 实验过程3.1 实验数据准备3.2 实验代码3.3 实验结果及分析4. 实验中遇到的问题 1.前言 1.1 多视图几何概念 多视图几何是利用在不同视点所拍摄图像间的关系,来研究照相机之间或者特征之间关系的一门科学。 多视图几何(Multiple View ...

RuiMa的博客 7729

【poj 3450 Corporate Identity 】 KMP(暴力)

C - Corporate Identity Time Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u SubmitStatusDescriptionBeside other services, ACM helps companies to clearly state their “corporate

ATOD 1060

为什么你的SiC MOSFET仿真不准?可能是离子注入的‘沟道效应’在捣鬼(Silvaco BCA模块详解)

本文深入分析了SiC MOSFET仿真中离子注入沟道效应的关键影响,揭示了Silvaco BCA模块在模拟SiC晶向和角度参数时的核心设置要点。通过详细解析晶圆偏切与注入角度的等效关系,提供优化MOSFET沟道区注入仿真的五步实战方法,帮助工程师将阈值电压仿真误差从26%降低到5%以内。

weixin_26789847的博客 418

HDU - 2328 Corporate Identity

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 Inter

那些年 2036

maxim max96712+max96717调试笔记

mxxim max96712 和max96717调试笔记

libuping2023的博客 1万+

DeepSeek-OCR安装部署文档和避坑指南,包含大多数人遇到的安装报错问题

DeepSeek-OCR安装部署指南摘要:本文详细介绍高性能OCR工具DeepSeek-OCR的安装流程,支持多语言识别和复杂场景文字提取。系统要求包括Linux/Windows/macOS操作系统,推荐NVIDIA显卡(显存≥6GB)和≥16GB内存。安装步骤涵盖:1)创建conda虚拟环境;2)安装PyTorch等核心依赖;3)解决常见问题如CUDA版本冲突、模型下载慢等。提供GPU内存不足等问题的解决方案,帮助开发者快速部署OCR服务。(149字)

yolo模型训练找我,AI游戏合作找我 3083

POJ3450:Corporate Identity(后缀数组)

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 Inter

ACM!荣耀之路! 2947

C# 与蓝牙 BLE 设备通信:基于 Windows.Devices.Bluetooth 实现手环/传感器数据读取

本文介绍了如何利用C#的Windows.Devices.Bluetooth命名空间实现与蓝牙BLE设备的通信。首先概述了BLE技术特性及其在物联网中的应用场景,包括智能穿戴设备和传感器。随后讲解了BLE的GATT协议架构,解析了服务(Service)和特性(Characteristic)的概念。文章重点展示了通过C#实现设备扫描、连接、数据读取的完整代码示例,并详细说明了如何使用通知(Notifications)功能实现实时数据更新。最后提供了订阅心率测量特性变化的实现代码,为开发者提供了完整的BLE设备通

这里只有干货:从 Modbus 通信到 MES 对接,从 YOLO 训练到工控机部署,带你搞定工业软件开发全流程。 1331

POJ 3450 Corporate Identity 求所有字符的最长公共子串(kmp)

Corporate Identity Time Limit:3000MS Memory Limit:65536K Total Submissions:9460 Accepted:3122 Description Beside other services, ACM helps companies to clearly state their...

qq_43813140的博客 381

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

POJ 3450 Corporate Identity(kmp求多个字符串的最长公共子串)

http://poj.org/problem?id=3450 #include <stdio.h> #include <string.h>const int max_N=4001; const int max_l=201;int n; char res[max_l],dict[max_N][max_l]; int nexts[max_N];int min(int a,int b){return a<

My_stage的博客 881

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

poj3450 Corporate Identity kmp || 后缀数组

题目:http://poj.org/problem?id=3450题意:给定n个字符串,求这n个字符串的最长公共子串思路:比较优的解法是枚举答案,然后用kmp或者strstr函数去判定枚举的子串是否是剩余所有字符串的子串。用后缀数组也可以,但是比较慢 kmp:#include <iostream> #include <cstdio> #include <cstring> #include <alg

弱智就要多努力 501

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

POJ 3450 Corporate Identity

POJ 3450 Corporate Identity Description Beside other services, ACM helps companies to clearly state their “corporate identity”, which includes company logo but also other signs, like trademarks. One o...

旺崽的博客 2480

POJ3450 Corporate Identity 最长公共子串

题目大意:给你n个字符串,让你找出他们的最长公共子串,如果存在多条,输出字典序最小的一个,若不存在,输出“IDENTITY LOST”。 分析:感觉就是 POJ1226,POJ3080 的综合。数据量不大,暴力就可以过。我感觉这题的考察点应该是字符串的排序,在找出m个最长公共子串后输出字典序最小的一个字符串才是本题的一个坑。 至于字符串排序,可以参考一下:字符串排序详解 实现

AC_Gibson的专栏 896

3450--Corporate Identity(后缀数组 多个字符串的最长公共子串)

poj3450-Corporate Identity 题意:给你n个字符串,求n个字符串内的最长公共子串,输出子串。 做法:将n个字符串连接起来,跑一遍sa和height数组,然后二分 公共子串长度,接着判断 height数组是否有连续的大于二分mid值 并且 来自n个不同的字符,维护即可。这里把字符转int类型做了,不然会超时 #include<cstdio> #include<cstring> #include<iostream> #define rin..

ccsu_deer 748

poj 3450 Corporate Identity

http://poj.org/problem?id=3450 Corporate Identity Description Beside other services, ACM helps companies to clearly state their “corporate identity”, which includes company logo but also ot

大太阳 372

[KMP或者暴力]POJ 3450 Corporate Identity

传送门:http://poj.org/problem?id=3450 题目大意:前面那道题类似,求多个字符串的最长且字典序最小的公共子串,还是枚举子串,然后拿去和剩余主串匹配,保存最优解。 代码: #include #include #include using namespace std; const int MAXN = 222,MAXM = 4444; char s[MAXM][MAX

Airarts_的专栏 891

poj3450 Corporate Identity(后缀数组+二分答案)

(http://www.elijahqi.win/2017/07/18/poj3450-corporat%E2%80%A6entity%EF%BC%88%E5%90%8E%E7%BC%80%E6%95%B0%E7%BB%84%E4%BA%8C%E5%88%86%E7%AD%94%E6%A1%88%EF%BC%89/) Corporate Identity Time Limit: 3000MS ...

Elijahqi 1755

[n串的最长公共子串][后缀数组]Corporate Identity POJ3450

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 wit

Cloth的博客 247

POJ-3450 Corporate Identity

枚举一个串的所有子串,和其余的串匹配,裸kmp的题。 #include #include #include using namespace std; const int maxn = 222; const int maxd = 4010; int f[maxn]; char str[maxn]; char t_str[maxn]; char c_str[maxd][maxn]; void ini

花月阁 752

poj 3450 Corporate Identity (KMP+最长公共子串)

题目链接:   poj 3450 题目大意:   给定n个字符串,找出最长的公共子串,若长度小于3则输出IDENTITY LOST 解题思路:   选出长度最短的字符串,枚举它的子串                   把它的子串分别与其余的n-1个字符串匹配                   字符串长度越短它的子串就越少,枚举量越少                   枚举子串的顺序

ンZee的解题报告 1489

poj3450 Corporate Identity

题意:给你若干个字符串,求它们的最长公共子串。对于相同长度的最长公共子串,取字典序最小的那个。 思路:枚举第一个字符串的所有可能子串,对后面所有字符串进行匹配。 #include #include #include using namespace std; const int maxn=1001; bool kmp(string a,string b) { int i,

gemini小窝 420
上一篇: Android百日程序:绘画程序-画手指路径
下一篇: POJ 3616 Milking Time 动态规划法题解
靖心
博客等级 码龄17年 684粉丝 746原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值