博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
fzu Problem 2128 最长子串 (注意strstr函数的使用)
阅读量:4035 次
发布时间:2019-05-24

本文共 894 字,大约阅读时间需要 2 分钟。

1、

2、题目:

对于每个子串,求出 母串中 所有该子串 的 开始和结束位置,保存在 mark数组中,求完所有子串后,对mark数组按 结束位置排序,然后 用后一个的结束位置 减去 前一个的 开始 位置 再 减去 1,记录最大值,

Problem 2128 最长子串

Accept: 50    Submit: 198
Time Limit: 3000 mSec    Memory Limit : 65536 KB

Problem Description

问题很简单,给你一个字符串s,问s的子串中不包含s1,s2...sn的最长串有多长。

Input

输入包含多组数据。第一行为字符串s,字符串s的长度1到10^6次方,第二行是字符串s不能包含的子串个数n,n<=1000。接下来n行字符串,长度不大于100。

字符串由小写的英文字符组成。

Output

最长子串的长度

Sample Input

lgcstraightlalongahisnstreet5strlongtreebigintegerellipse

Sample Output

12

 

3、代码:

#include
#include
#include
using namespace std;#define N 1000005char str[N];char sub[105];int cnt;struct node{ int start; int end;}a[N];int cmp(node a,node b){ return a.end
ans) ans=tmp; } if(ans==-1) printf("%d\n",l); else printf("%d\n",ans); } return 0;}/*lgcstraightlalongahisnstreet5strlongtreebigintegerellipse*/

 

转载地址:http://beddi.baihongyu.com/

你可能感兴趣的文章
android中对于非属性动画的整理
查看>>
一个简单的TabLayout的使用
查看>>
ReactNative使用Redux例子
查看>>
Promise的基本使用
查看>>
android给文字加边框(修改不能居中的问题)
查看>>
coursesa课程 Python 3 programming 统计文件有多少单词
查看>>
coursesa课程 Python 3 programming 输出每一行句子的第三个单词
查看>>
coursesa课程 Python 3 programming Dictionary methods 字典的方法
查看>>
Returning a value from a function
查看>>
coursesa课程 Python 3 programming Functions can call other functions 函数调用另一个函数
查看>>
coursesa课程 Python 3 programming The while Statement
查看>>
course_2_assessment_6
查看>>
coursesa课程 Python 3 programming course_2_assessment_7 多参数函数练习题
查看>>
coursesa课程 Python 3 programming course_2_assessment_8 sorted练习题
查看>>
在unity中建立最小的shader(Minimal Shader)
查看>>
1.3 Debugging of Shaders (调试着色器)
查看>>
关于phpcms中模块_tag.class.php中的pc_tag()方法的含义
查看>>
vsftp 配置具有匿名登录也有系统用户登录,系统用户有管理权限,匿名只有下载权限。
查看>>
linux安装usb wifi接收器
查看>>
补充自动屏蔽攻击ip
查看>>