题目: BZOJ2565 分析: 首先看到回文串,肯定能想到Manacher算法.下文中字符串\(s\)是输入的字符串\(str\)在Manacher算法中添加了字符'#'后的字符串 (构造方式如下) string s = "#"; for (int i = 0; i < str.size(); i++) { s += str[i]; s += '#'; } 如果用\(maxl_i\)表示以第\(i\)个字符结尾的最长回文串的长度,\(maxr_i\)表示以第\(i\)个字符开头…
传送门 题意简述:问最长的由两个回文串连接而成最长字串长度. 思路: 正反串各建一个pampampam然后就完了. 代码: #include<bits/stdc++.h> #define ri register int using namespace std; const int N=1e5+5; int n,f[N][2],ans=0; char s[N]; struct pam{ int son[N][26],fail[N],len[N],tot,last,siz[N]; pam(){le…
https://www.lydsy.com/JudgeOnline/problem.php?id=2565 正着构造回文自动机 倒过来再构造一个回文自动机 分别求出以位置i开始的和结尾的最长回文串 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; #define N 100001 char ss[N]; int s[N]; int L1[N],L2[N]; struct…
E. Palisection time limit per test 2 seconds memory limit per test 128 megabytes input standard input output standard output In an English class Nick had nothing to do at all, and remembered about wonderful strings called palindromes. We should remin…