fzu Problem 2128 最长子串
来源:互联网 发布:java命令行运行jar包 编辑:程序博客网 时间:2024/06/11 02:10
http://acm.fzu.edu.cn/problem.php?pid=2128
#include"stdio.h"
#include"string.h"
#include"stdlib.h"
struct point
{
int x;
int y;
}sum[1000006];
int cmp(const void *a,const void *b)
{
struct point *c=(point *)a;
struct point *d=(point *)b;
return c->x-d->x;
}
char s[1000006],a[1006][106];
int main()
{
int i,j,k,h;
while(scanf("%s",s)!=EOF)
{
j=0;
int max=-1,pp;
scanf("%d",&k);
for(i=0;i<k;i++)
{
h=0;
scanf("%s",a[i]);
while(strstr(s+h,a[i])!=NULL)
{
sum[j].x=strstr(s+h,a[i])-s;
h=strstr(s+h,a[i])-s+strlen(a[i])-1;
sum[j].y=h;
j++;
}
}
sum[j].x=sum[j].y=strlen(s);
j++;
qsort(sum,j,sizeof(sum[0]),cmp);
for(i=0;i<j-1;i++)
{
pp=sum[i+1].y-sum[i].x-1;
if(pp>max)
max=pp;
}
if(max!=-1)
printf("%d\n",max);
else
printf("%d\n",strlen(s));
}
return 0;
}
- fzu Problem 2128 最长子串
- fzu Problem 2128 最长子串
- fzu Problem 2128 最长子串
- 【FZU】Problem 1411 最长配对子串
- FZU 2128 最长子串
- fzu 2128 最长子串
- fzu Problem 2128 最长子串 (注意strstr函数的使用)
- 福州大学第十届校赛 & fzu 2128最长子串
- Problem 2128 最长子串 (KMP+字符串 好题)
- fuzhuo------ Problem 1411 最长配对子串
- leetcode Problem 5 最长子回文串
- fzu——Problem 2088 最长队名
- fzu Problem 2129 子序列个数
- 【最长回文子串】【平衡树】[HDU5371]Hotaru's problem
- fzu—— Problem 2129 子序列个数
- fuz--2128(最长子串)
- 【CodeCraft比赛】Problem 7——X-man(最长公共子串LCS变种)
- 【面试笔试算法】Problem 9: 腾讯2016年研发实习笔试题:最长回文子串
- SDL多线程问题之--Unknown request in queue while dequeuing
- DAVINCI DM365-DM368开发攻略——U-BOOT-2010.12及UBL的移植
- Spring、Hibernate 解耦方法与设计模式(1)
- inline-block 理解
- 题目1451:不容易系列之一
- fzu Problem 2128 最长子串
- servlet 处理登陆表单数据(数据库)主要代码实现
- OCP-1Z0-053-V13.02-486题
- FileUtil
- SVN--项目管理的好帮手(-)
- J2EE login
- 我的阿里,百度面试经
- netty时间轮HashedWheelTimer
- 【Unity3D自学记录】批量创建预设(Prefabs)