Theme Section HDU - 4763 (kmp)

SAP Script表单开发中ABAP preform方法的实战应用与调试技巧 本文深入探讨了在SAP Script表单开发中调用ABAP程序(preform方法)的实战应用与调试技巧。通过一个获取供应商版本名称的实例,详细讲解了如何在SE71中嵌入PERFORM指令、编写ABAP子程序进行数据查询与处理,并重点介绍了使用SAP Script Debugger进行高效调试的方法,帮助开发者灵活扩展表单功能,实现复杂业务逻辑。 阅读详情

Theme Section

HDU - 4763

It's time for music! A lot of popular musicians are invited to join us in the music festival. Each of them will play one of their representative songs. To make the programs more interesting and challenging, the hosts are going to add some constraints to the rhythm of the songs, i.e., each song is required to have a 'theme section'. The theme section shall be played at the beginning, the middle, and the end of each song. More specifically, given a theme section E, the song will be in the format of 'EAEBE', where section A and section B could have arbitrary number of notes. Note that there are 26 types of notes, denoted by lower case letters 'a' - 'z'.

To get well prepared for the festival, the hosts want to know the maximum possible length of the theme section of each song. Can you help us?

Input
The integer N in the first line denotes the total number of songs in the festival. Each of the following N lines consists of one string, indicating the notes of the i-th (1 <= i <= N) song. The length of the string will not exceed 10^6.
Output
There will be N lines in the output, where the i-th line denotes the maximum possible length of the theme section of the i-th song.
Sample Input
5
xy
abc
aaa
aaaaba
aaxoaaaaa
Sample Output
0
0
1
1
2
利用Next数组,这样最长前后缀就得到了,然后只需要用kmp在看一下中间部分是否有这一段字符串就可以了

code:

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 1e6+100;
char s[MAXN];
int Next[MAXN];
void getNext(){
    int i = -1,j = 0;
    int len = strlen(s);
    Next[0] = -1;
    while(j < len){
        if(i == -1 || s[i] == s[j]){
            i++,j++;
            Next[j] = i;
        }
        else
            i = Next[i];
    }
}
bool kmp(int st){
    int i = 0,j = st;
    int n = strlen(s);
    while(j < n-st){
        if(i == -1 || s[i] == s[j])
            i++,j++;
        else
            i = Next[i];
        if(i == st)
            return true;
    }
    return false;

}
int main(){
    int t;
    scanf("%d",&t);
    while(t--){
        int i,j,len,Max = 0;
        scanf("%s",s);
        len = strlen(s);
        if(len < 3){
            printf("0\n");
            continue;
        }
        getNext();
        while(Next[len] != -1){
            if(Next[len] > Max && kmp(Next[len])){
                Max = Next[len];
                break;
            }
            len = Next[len];
        }
        printf("%d\n",Max);
    }
    return 0;
}



基于ESP32-P4的低成本旋转式激光雷达系统设计 激光雷达(LiDAR)作为机器人环境感知的核心传感器,其本质是融合光学测距、机电控制与实时数据处理的嵌入式系统。理解时间飞行(ToF)原理与机械旋转耦合机制,是实现高精度点云采集的基础;而系统级误差源——如计时抖动、电机惯性、信号串扰和温漂——直接决定实际建图鲁棒性。在资源受限场景下,选用RISC-V双核MCU(如ESP32-P4)可兼顾实时控制与网络服务能力,通过硬件时间戳捕获、S型加减速轨迹规划、旋转变压器供电及双Bank OTA等工程手段,有效平衡分辨率、帧率与稳定性。本文围绕360°旋转式激光雷达的 阅读详情

相关推荐

超聚变安装银河麒麟服务器系统ky10-server-x86

超聚变-通过BMC口进服务器管理界面如下图为BMC管理口:默认BMC口IP:https://192.168.2.100l浏览器打开网页,输入用户名和密码登陆后,如下图红框处,选择“启动虚拟控制台”——选择“HTML集成远程控制台”系统银河麒麟服务器系统ky10 server x86选择镜像文件X86架构我们一般选择下图2212版本选择启动方式:光驱重启出现安装图形化界面选装安装系统的磁盘系统安装盘选完后如下图,会置灰创建root密码开始安装系统首次进入,有协议界面。

zengliguang的专栏 5961

Theme Section⭐⭐(kmp!!)题意+思路

It's time for music! A lot of popular musicians are invited to join us in the music festival. Each of them will play one of their representative songs. To make the programs more interesting and challenging, the hosts are going to add some constraints to t.

with_wine的博客 289

Xilinx Vivado LDPC IP core,TSN IP core. 各种IP core

Xilinx Vivado LDPC IP core,TSN IP core. 各种IP core

qq_1432825237的博客 3991

Theme Section(主题部分)(kmp经典模板题) HDU - 4763

题目:Theme Section(主题部分)中文大意 It’s time for music! A lot of popular musicians are invited to join us in the music festival. Each of them will play one of their representative songs. To make the programs more interesting and challenging, the hosts are going to

R_711的博客 332

别再死记硬背Payload了!深入理解Flask/Jinja2 SSTI的Python对象继承链与魔术方法

本文深入解析Flask/Jinja2 SSTI漏洞的底层原理,从Python对象模型出发,详细讲解如何通过魔术方法链实现RCE。文章揭示了Python对象继承链与魔术方法的精妙设计,提供了防御与绕过SSTI漏洞的实用技巧,帮助开发者深入理解漏洞本质并采取有效防护措施。

weixin_42525738的博客 356

小案例:利用图床自动化批量上传图片并获取图片链接

用python爬虫写了一个小脚本,用来自动上传图片到图床,然后返回链接,我们只需直接复制链接就可以。(需要安装Requests库) 因为不同图床需要提交的POST表单不一致,所以在这里我用ImgURL图床做示范,如果大家有需求,可自行修改代码。使用脚本的时候,我们只需把需要上传的图片和这个脚本放在同一个文件夹中,然后运行脚本,稍作等待,看到提示时就可以在脚本运行文件夹中发现一个名为“图片链接地址.txt”的文件,里面就是图片链接啦! 四、图片链接地址.txt(单张图片):...

采菊东篱下,Python满乾坤! 4409

KMP-Theme Section

Description It’s time for music! A lot of popular musicians are invited to join us in the music festival. Each of them will play one of their representative songs. To make the programs more interesting and challenging, the hosts are going to add some const

weixin_43856210的博客 146

【异常】 OpenClaw 超长入参报错排查与解决方案 [错误]: 400 <400> InternalError.Algo.InvalidParameter: Range of input leng

摘要: OpenClaw服务调用出现400 InvalidParameter报错,核心原因为输入内容长度超出1-129024字符限制。解决方案包括:1)紧急精简冗余入参;2)标准分块处理长文本;3)客户端增加预校验模块;4)长期可申请调整服务规格。该错误属于客户端参数校验异常,通过合理控制输入长度或分批次处理即可解决,重点需保证语义完整性。建议优先采用自动化预校验机制,从源头预防问题发生。(149字)

奶爸的编程之路,也就一周冷个三天 1987

【HDU】 4763 Theme Section (KMP)

Theme Section Problem Description It's time for music! A lot of popular musicians are invited to join us in the music festival. Each of them will play one of their representative songs. To mak

Silence的程序实验室 1297

华为OD机试真题2026双机位C卷 Python&JS 语言 实现【主次关联成环警告】

在ICT运维领域,现网运维工程师面向对设备上报的众多告警,往往需要筛选出最主要的告警优先处理,次等级的告警或许为同一个根因导致的告警,处理优先级会放后或者不处理,这样就诞生出主次关联告警的概念。给定一系列告警的主次关联关系,判断是否存在如下情况:

MISAYAONE的博客 269

Python爬虫教程:抓取电商网站评论(以淘宝和京东为例)

通过本文的介绍,我们学会了如何使用Python编写爬虫,抓取淘宝和京东等电商平台的商品评论数据。我们介绍了如何使用电商平台提供的开放API以及如何通过模拟浏览器来抓取动态加载的数据。此外,我们还讨论了如何应对反爬虫技术,如何存储抓取的数据等。爬取电商平台的数据是一个强大的工具,能够为市场分析、消费者行为研究、产品优化等领域提供有力的支持。然而,在使用爬虫技术时,我们必须遵循法律法规,尊重平台的隐私政策,避免滥用数据。

2201_76125261的博客 1737

HDU 4763 字符串的前中后三段公共子串

Description It's time for music! A lot of popular musicians are invited to join us in the music festival. Each of them will play one of their representative songs. To make the programs more interes

became_a_wolf的专栏 596

Jetson AGX Orin平台Jetpack5升级Jetpack6,自研载板USB不工作问题调试

1. 问题描述将AGX Orin工业的新板放到定制的载板上当在ubuntu 22和Jetpack 6.1上使用SDKManager刷机时,lsusb为空,并且在引导时没有发现/注册xusb设备。USB C端口正常打开并供电,但似乎没有数据传输。在Ubuntu 18 Jetpack 5.1.4 SDKManager上同样刷机之后,usb C集线器在引导时被正确地发现,显示在lsusb中,并识别/挂载外部驱动器。

jzwjzw19900922的博客 1509

HDU4763 Theme Section 【KMP】

Theme Section Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1114    Accepted Submission(s): 579 Problem Description It's time for

长风的专栏 1370

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

hdu 4763 Theme Section(KMP)

题目链接:  hdu 4763 题目大意:  找出字符串的最长子串,这个子串满足既是前缀和后缀,并且在中间会出现 解题思路:  不妨先找出所有前缀等于后缀的子串长度(poj 2752 解题报告)                    从长到短(长度不大于主串的1/3)枚举子串的长度                   前缀等于后缀的子串长度为ans[ i ]            

ンZee的解题报告 1216

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

HDU4763 Theme Section(KMP)

题目链接:hdu4763 题面 题目大意 找到字符串中的最长公共前后缀,并且这个前后缀的字串在除了前后缀的中间部分也要存在这个子串。例如:EAEBE,其中,E 表示这个子串,输出 E 的最大长度,如果不存在输出 0 。 解题思路 KMP 利用求失配函数得到串的最长公共前后缀,然后从 2i 的位置到 len-i 的位置开始枚举中间是否存在子串,判断条件是: fail[j]==ifail[j]==ifail[j]==i。含义是失配指针能够索引到公共前缀后一个位置,然后从 j 位置到达 i 表示 0 - j

小胡同的诗 304

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

Hdu 4763 Theme Section KMP

Theme Section Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3667    Accepted Submission(s): 1721 Problem Description It's time fo

J. Cole 441

HDU4763 Theme Section KMP

HDU4763 Theme Section KMP 字符串满足EAEBE,E为相同的前后缀,只需在中间找出另一个E即可 利用nxt数组的性质,找出E即可 /*KMP字符串匹配 next[i]记录1~i中相同前后缀长度-1 即相同字符下标位置 171MS 6108K */ #include &lt;stdio.h&gt; #include &lt;string.h&gt; const int...

Qianyri的博客 323

HDU 4763 Theme Section(KMP)

【链接】http://acm.hdu.edu.cn/showproblem.php?pid=4763 【题意】给个字符串,求满足形如“E...E...E”这种鬼样子的E串最大长度,其中“...”可以是任意个数的任意字符(没有也ok),但是三个E之间不能重叠 【思路】 无视中间那个“E”的话,其实是在求前后缀相同的最大缀长 回头看一眼刚刚写完的poj 2752,终于知道为什么搜题解的

无色城 956

hdu4763 Theme Section KMP

给一个字符串S,问是否存在一个子串s'同时为s的前缀,后缀,并且至少出现在前缀后缀之外的位置一次(互不重叠)。10^6的数据...一开始想写后缀数组,看这数据估计是要卡倍增,DC3又没写过..后来想了想直接KMP扫一遍好像就行..以末尾为起点,遍历从失配路径上的每一个点,如果f[j]小于len/3,那么就从2*f[j]+1~len-f[len] 之间枚举k看是否存在f[k]==f[j],存在的话答

Broken Wings 736

HDU 4763 Theme Section(KMP)

题目链接:点击打开链接 题意:给你一个字符串s, 要你求是否存在一个子串, 在s的前中后各出现一次。 求最大可能的子串长度。 思路:KMP变形, 我们首先要了解KMP的运行机制。  核心是失配函数f, f[i]表示在i点失配之后返回到f[i]这个点, 且能保证f[i]之前的部分和模板串匹配。  这样的话, 我们就可以利用这个特点来处理该题了。 我们假设在最后一个字符处失配, 那么它将返回f[l

AC_Arthur的专栏 1189

Theme Section HDU - 4763(kmp )

Theme Section HDU - 4763 题意: 给你一个字符串s。 要求你找到最长的前缀&&中缀&&后缀。 思路: 可以对串s求next 假如nxt【len】x 3 >len.(那么说明太长了,要缩短) 可以len=nxt【len】。 之后贪心的找就可以了。把s按照长度next【len】切割成 三部分。 (nxt【len】+(len-nxt【len】-nxt【len】)+nxt【len】) 对长度为nxt【len】的字符串,再求一次next2. 把它与中间

qq_45377553的博客 163

hdu 4763 Theme Section kmp

这个next[i]表示的就是最长前后缀,那么头和尾的就不next就可以得出了 那么就剩下判断中间是否存在了,中间的只要不重叠的那部分存在一个next[j]大于的就可以了。 中间的部分是不断扩大的,那么就头尾不断next,中间不断更新新加入的节点即可。 #include #include #include using namespace std; const int maxn=1e6+9

yrleep的专栏 1060

hdu 4763 Theme Section (扩展kmp)

hdu 4763 Theme Section (扩展kmp) 题目大意:给出一个字符串,问这个字符串的最长Theme Section是多长,Theme Section要符合以下条件,必须出现在字符串的开头,结尾,和中间,而且不能有重叠。 很抱歉,之前写了个很挫o(nlogn)的解法,误导了大家,后来我仔细想了想,其实用扩展kmp可以o(n)的实现。下面给出具体的实现方法: 解题思路:还是

No__stop 2183

扩展kmp -- Theme Section HDU - 4763

Theme Section HDU - 4763 题意: T次询问,每次给你一个字符串s(|s| <= 1e6),找到一个最长的子串,出现在s的串首、串中、串尾位置,互不重叠。输出这个子串的长度。 思路: 先用扩展kmp处理出s每位s[i]开头的的子串与前缀的最大长度,保存在nxt数组中,从尾部开始遍历nxt数组,如果i + nxt[i] = |s|(s的长度),则说明检索出了串首、串尾的两个子串,那再检索串中的子串是否存在,并在检索的过程中保证串首、串中、串尾的子串互不重叠。 code: #incl

dajiangyou123456的博客 342

HDU 4763 Theme Section(kmp)

Time Limit:1000MS Memory Limit:32768KBDescription It’s time for music! A lot of popular musicians are invited to join us in the music festival. Each of them will play one of their representative s

2cm的专栏 377
上一篇: 最长回文 HDU - 3068 (Manacher算法)
下一篇: Phone List POJ - 3630 (字典树或string)
Guuuuuu老师儿
博客等级 码龄9年 259粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值