
字符串
十一号路口。
博客仅用于本人记录学习笔记!
展开
-
(转) 最长回文子串线性算法 manacher算法讲解
Manacher’s Algorithm – Linear Time Longest Palindromic Substring – Part 2InManacher’s Algorithm – Part 1, we gone through some of the basics and LPS length array.Here we will see how to calculate ...转载 2019-11-25 11:35:00 · 180 阅读 · 0 评论 -
(转)后缀数组讲解
目录什么是后缀数组 前置知识 后缀 基数排序 倍增法 过程详解 基数排序 height数组 经典应用 两个后缀的最大公共前缀 可重叠最长重复子串 不可重叠最长重复子串 POJ1743 本质不同的子串的数量 后记回到顶部什么是后缀数组后缀数组是处理字符串的有力工具 —罗穗骞个人理解:后缀数组是让人蒙逼的有力工具!就像上面那位大...转载 2019-11-18 20:54:49 · 586 阅读 · 0 评论 -
UVA11468 Substring --- AC自动机
题解: 按照蓝书的解法,先把所有单词建trie树,然后生成一个字符就等价于在trie上面走一步,只要不走到单词节点即可,所有用dp(u,l)表示当前在u节点上,还剩l个字符时,满足题意的概率。需要注意的是,getFail()中if(isWord[]) ... 的那行代码比较关键,缺掉就会WA。原因是在常规的AC自动机中,在字符串中每移动一个字符,就要反复通过fail指针来找是否有以当前字符结...原创 2019-11-16 11:22:04 · 189 阅读 · 0 评论 -
UVA11732 strcmp anyone --- 字典树
题解: 遍历每个单词,插入到字典树中,插入的过程中根据每个节点处的信息来计算比较次数,注意如果用指针来表示字典树的话会超时,估计是因为构造Trie的时候会遍历next数组,导致时间复杂度增加一个数量级。#include <cstdio>#include <cstring>#include <algorithm>using namespace st...原创 2019-11-12 10:32:50 · 174 阅读 · 0 评论 -
计蒜客-版本号控制 字符串处理
题目链接https://www.jisuanke.com/course/1797/171534题解:写一个排序函数cmp,然后调用内置的sort函数排序即可写cmp的话就用sscanf函数处理,每次输入各一个整数比较,一样的话指针后移继续比较,具体思路看代码注意:自己写的cmp(x,y)函数返回值含义是x是否小于y,不是x-y的值,要是返回的是x-y的值,有一半的数...原创 2019-03-06 21:44:17 · 296 阅读 · 0 评论 -
HDOJ3460 Ancient Printer ---- 字典树
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=3460Problem DescriptionThe contest is beginning! While preparing the contest, iSea wanted to print the teams' names separately on a single paper.Unf...原创 2018-10-31 19:04:08 · 216 阅读 · 0 评论 -
HDOJ 3613 Best Reward --- 扩展KMP算法求前(后)缀回文串
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=3613Problem DescriptionAfter an uphill battle, General Li won a great victory. Now the head of state decide to reward him with honor and treasures fo...原创 2018-10-20 10:07:38 · 235 阅读 · 0 评论 -
HDOJ2087剪花布条-----KMP算法模板题
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=2087Problem Description一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案。对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出几块小饰条来呢? Input输入中含有一些数据,分别是成对出现的花布条和小饰条,其布条都是用可见ASCII字...原创 2018-10-10 17:06:16 · 175 阅读 · 0 评论 -
HDOJ3746 Cyclic Nacklace --- KMP求最小循环节
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=3746Problem DescriptionCC always becomes very depressed at the end of this month, he has checked his credit card yesterday, without any surprise, the...原创 2018-10-19 09:41:00 · 153 阅读 · 0 评论 -
HDOJ3336Count the string-----KMP求前缀串重复次数
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=3336Problem DescriptionIt is well known that AekdyCoin is good at string problems as well as number theory problems. When given a string s, we can wr...原创 2018-10-11 09:10:11 · 179 阅读 · 0 评论 -
HDOJ3068最长回文 ---- Manacher算法
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=3068 Problem Description给出一个只由小写英文字符a,b,c...y,z组成的字符串S,求S中最长回文串的长度.回文就是正反读都是一样的字符串,如aba, abba等 Input输入有多组case,不超过120组,每组输入为一行小写英文字符a,b,c....原创 2018-10-02 11:51:53 · 175 阅读 · 0 评论 -
HDOJ1251统计难题(trie树模板题)
题目链接 点击打开链接字典树模板题,唯一需要注意的就是空行的处理..#include <cstdio>#include <iostream>#include <cstring>using namespace std;char ch[15]; //接受输入 int num; struct Node{ int count; Node *next[2...原创 2018-05-21 09:23:34 · 209 阅读 · 0 评论 -
POJ2406 Power Strings-KMP算法求循环节( KMP经典题)
在网上搜KMP经典题复习KMP时,无意看到了用next数组求最小循环节的题,感觉这种方法还是比较简单而且巧妙的,学习了。题目链接 :点击打开链接 具体原理:next数组求循环节的应用#include <cstdio>#include <iostream>#include <cstring>using namespace std;char ch[10000...转载 2018-05-18 10:00:07 · 300 阅读 · 0 评论