![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
字符串匹配
哇-WA
这个作者很懒,什么都没留下…
展开
-
字符串匹配-KMP算法
题目要求:给你两个字符串T,P。查找T串中是否存在P串。一般思路:从T的第一个元素开始遍历,不断匹配P中的元素,如果当前位置元素匹配失败了,就重新从P的第一个元素开始匹配。#include <stdio.h>#include<string.h>char P[105],T[105];int main(){ scanf("%s%s",T,P); int ...原创 2017-10-24 21:37:08 · 716 阅读 · 0 评论 -
最长回文子串-Manacher算法模板
模板:#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;#define MAXN 2000005int n,ans,p[MAXN];char str[MAXN];void Manacher(){ int mx=0,id=0; n=n*...原创 2018-04-14 21:12:28 · 129 阅读 · 0 评论 -
CKOJ 1071: zdw的嘤嘤嘤【维护前缀变量】
1071: zdw的嘤嘤嘤时间限制: 1 Sec 内存限制: 128 MB提交: 52 解决: 13[提交][状态][讨论版]题目描述//感觉会被zdw揍众所周知,zdw是一个萌妹,喜欢嘤嘤嘤。而且最擅长八重嘤和嘤雄不朽。这一天zdw说了一个很长的字符串,只包括 ‘y’ , ‘i’ , ‘n’ ,’g’这四个字符。你需要选取尽量多的下标,让这些下标在这个字符串中对应的字符按下标从小到大的顺序组...原创 2018-04-13 10:20:59 · 301 阅读 · 0 评论 -
CodeForces - 471D MUH and Cube Walls 【KMP】
D. MUH and Cube Wallstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant ...原创 2018-05-04 15:33:09 · 214 阅读 · 0 评论 -
牛客网暑期ACM多校训练营(第三场)E Sort String【KMP or hash】
题目链接:https://www.nowcoder.com/acm/contest/141/E 思路:可以用KMP,也可以用hash。讲一下KMP的思路。经过观察发现,如果字符串存在循环节,且长度为k,那么显然可以分k组。从一个循环节内不同位置开始,都可以分为不同组。那么问题就变成了找循环节。我们可以利用KMP的失配函数来寻找循环节。循环节的长度k=len-f[len]。如果len...原创 2018-07-27 22:58:36 · 114 阅读 · 0 评论