字符串
Steaunk
Remember to look up at the stars and not down at your feet. Be curious and however difficult life may seem, there is always something you can do and succeed at. - SH
展开
-
「POJ 3693」Maximum repetition substring
题意:求一个串的最大重复次数的重复子串,要求输出字典序最小。 后缀数组,可以看罗穗骞的论文《后缀数组——处理字符串的有力工具》。 #include #include #define Max(_A, _B) (_A > _B ? _A : _B) #define Min(_A, _B) (_A #define R register char s[100010], t[100010];原创 2017-11-30 22:04:15 · 319 阅读 · 0 评论 -
SAM模板
以 luogu P3804 为例感觉我对 SAM 理解的不是很透彻。#include <cstdio> #include <cstring> #define R register #define Null b #define Max(_A, _B) (_A > _B ? _A : _B) char s[1000010]; struct Data { int len, size, In;原创 2018-03-02 22:20:30 · 474 阅读 · 0 评论 -
Trie图
Trie图是AC自动机的优化。 以 luogu P3808 为例原创 2017-11-27 13:15:06 · 275 阅读 · 0 评论 -
后缀排序
以 luogu P3809 为例 #include #include #define R register const int MaxN = 1000010; int SA[MaxN], Rank[MaxN], Height[MaxN], x[MaxN], sum[MaxN], y[MaxN]; char s[MaxN]; bool cmp(R int i, R int j, R int k原创 2017-11-28 09:36:22 · 868 阅读 · 0 评论 -
manacher 算法
目标 给定一个字符串 SSS,求出以每一个点为中心的最长的回文子串的长度。 预处理 首先对于字符串如 abaccaa,将其两两字符之间插入一个#,并在首尾各插入一个不常用的字符(避免边界问题),如变为?#a#b#a#c#c#a#a#$,这样的一个新串在处理时就无需考虑长度为偶数的回文子串,如回文子串 acca 在新...原创 2019-04-23 13:35:20 · 208 阅读 · 0 评论