Palindromes and Super Abilities Problem's Link: http://acm.timus.ru/problem.aspx?space=1&num=1960 Mean: 给你一个长度为n的字符串S,输出S的各个前缀中回文串的数量. analyse: 回文树(回文自动机)的模板题. 由于回文自动机中的p是一个计数器,也相当于一个指针,记录的是当前插入字符C后回文树中有多少个节点. 那么我们只需要一路插,一路输出p-2就行. p-2是因为一开始回文树中就有两个…
Palindromes and Super Abilities Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged on Ural. Original ID: 196064-bit integer IO format: %lld      Java class name: (Any) After solving seven problems on Timus Online Judge with a word “…
2040. Palindromes and Super Abilities 2 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=2040 Description Dima adds letters s1, -, sn one by one to the end of a word. After each letter, he asks Misha to tell him how many new palindrome substrings a…
Palindromes and Super Abilities 2 Time Limit: 1MS   Memory Limit: 102400KB   64bit IO Format: %I64d & %I64u Status Description Dima adds letters s1, -, sn one by one to the end of a word. After each letter, he asks Misha to tell him how many new pali…
Palindromes and Super Abilities 2 题目链接: http://acm.hust.edu.cn/vjudge/contest/126823#problem/E Description Dima adds letters s 1, -, s n one by one to the end of a word. After each letter, he asks Misha to tell him how many new palindrome substrings…
http://acm.timus.ru/problem.aspx?space=1&num=1960 题意:给一个串s,要求输出所有的s[0]~s[i],i<|s|的回文串数目.(|s|<=10^5) #include <bits/stdc++.h> using namespace std; struct PT { static const int nS=26, nL=100015, N=nL; int f[N], l[N], c[N][nS], id[N], s[nL],…
Bryce1010模板 http://acm.timus.ru/problem.aspx?space=1&num=1960 #include <bits/stdc++.h> using namespace std; const int maxn = 100010; struct PalindromicTree{ int fail[maxn],len[maxn],son[maxn][26]; int tot,last,n; char s[maxn]; int newnode(int sl…
Palindromes and Super Abilities 2Time Limit: 500MS Memory Limit: 102400KB 64bit IO Format: %I64d & %I64u Description Dima adds letters s1, …, sn one by one to the end of a word. After each letter, he asks Misha to tell him how many new palindrome sub…
回文树/回文自动机 放链接: 回文树或者回文自动机,及相关例题 - F.W.Nietzsche - 博客园 状态数的线性证明 并没有看懂上面的证明,所以自己脑补了一个... 引理: 每一个回文串都是字符串某个前缀的最长回文后缀. 证明. 考虑一个回文串在字符串中第一次出现的位置, 记为 \(S_{p_1 ... p_2}\), 它一定是 \(S_{1 ... p_2}\)的最长回文后缀. 否则, 如果有 \(S_{p_3 ... p_2} (p_3<p_1)\) 也为回文串, 那么由于回文, \…
回文树学习博客:lwfcgz    poursoul 边写边更新,大概会把回文树总结在一个博客里吧... 回文树的功能 假设我们有一个串S,S下标从0开始,则回文树能做到如下几点: 1.求串S前缀0~i内本质不同回文串的个数(两个串长度不同或者长度相同且至少有一个字符不同便是本质不同) 2.求串S内每一个本质不同回文串出现的次数 3.求串S内回文串的个数(其实就是1和2结合起来) 4.求以下标i结尾的回文串的个数 每个变量的含义 1.len[i]表示编号为i的节点表示的回文串的长度(一个节点表示…