字符串整理(Manachar,KMP,扩展KMP,ACAM,SA,SAM,最小表示法) 基础 字符集$\sum$:一个字符集是一个建立了全序关系的集合,即任意属于$\sum$的元素可以比较,字符集中的元素叫做字符 字符串:一个字符串$S$将n个字符顺次排列组成,$n$为$S$的长度,计作$|S|$, ...
分类:
其他好文 时间:
2020-07-26 01:32:53
阅读次数:
67
拉两次车,第一次假设最长回文串就在两边 第二次,先使得左右两边判回文,在将剩下的串 在manachar一遍, 比较两种情况取最大值,然后就是输出问题见代码 #include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 5; ...
分类:
其他好文 时间:
2020-03-31 01:01:15
阅读次数:
71
题意 给你两个串,可以翻转a串的一个区间,问有多少对l,r使得翻转后的a串等于b串 题解 沙比提,比赛时想了想两个串相等就用马拉车求回文子串个数,觉得两个串不相等情况很复杂就没想下去了,其实两个串不相等的情况更好处理 两个串不一样的话,一定需要翻转第一个和最后一个不相等的位置(关键),判一下中间是不 ...
分类:
其他好文 时间:
2019-04-28 09:49:22
阅读次数:
150
1、模板 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int MAX=21000020; 4 char s[MAX],t[MAX<<1]; 5 int p[MAX<<1],cnt=0,mid,mr; 6 void manachar ...
分类:
其他好文 时间:
2019-02-16 13:18:38
阅读次数:
145
题目描述 https://www.lydsy.com/JudgeOnline/problem.php?id=3160 题解 先把问题转化一下,我们要求的是非连续对称回文子序列。 ans=回文子序列数-回文子串数。 回文子串数可以用PAM或manachar求出来。 复习了一下PAM,用它求回文子串数和 ...
分类:
其他好文 时间:
2019-01-01 21:13:43
阅读次数:
157
学弟lyh上午讲课,喜闻乐见的制胡窜 一上午讲惹KMP, manachar, trie树, AC自动机 orz 例题都是洛咕咕上的, 贴一下(督促自己不要咕 AC自动机不会qaq(并且没有学的意向 manachar 没写过 P4555 [国家集训队]最长双回文串 kmp 不熟 P3435 [POI2 ...
分类:
其他好文 时间:
2018-10-20 11:43:18
阅读次数:
141
原文链接http://www.cnblogs.com/zhouzhendong/p/8810140.html 题目传送门 - BZOJ3160 题意 给你一个只含$a,b$的字符串,让你选择一个子序列,使得: $1.$位置和字符都关于某一条对称轴对称。 $2.$不能是连续的一段。 问原来的字符串中能 ...
分类:
其他好文 时间:
2018-04-12 20:54:46
阅读次数:
152
#include using namespace std; char str[20005],str1[40005],len=0; int p[40005]; int manachar(){ int id=0,maxn=0,ans=0,j=1; str1[0]='@'; for(int i=0;ima... ...
分类:
其他好文 时间:
2017-11-09 20:49:45
阅读次数:
116
UVA 11888 - Abnormal 89's 题目链接 题意:给定一个字符串。推断类型。一共三种。两个回文拼接成的,一个回文,其他 思路:利用Manachar处理出每一个位置的最长回文,然后扫描一遍去推断就可以 代码: #include <cstdio> #include <cstring> ...
分类:
其他好文 时间:
2017-07-30 17:14:42
阅读次数:
123
#include <cstdio> #include <iostream> #include <algorithm> #include <queue> #include <cmath> #include <cstring> #include <stack> #include <set> #inclu ...
分类:
其他好文 时间:
2017-07-23 13:42:46
阅读次数:
199