CA Loves Palindromic Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 301    Accepted Submission(s): 131 Problem Description CA loves strings, especially loves the palindrome strings. One day…
Alice get a string S. She thinks palindrome string is interesting. Now she wanna know how many three tuple (i,j,k) satisfy 1≤i≤j<k≤length(S) , S[i..j] and S[j+1..k] are all palindrome strings. It's easy for her. She wants to know the sum of i*k of al…
URAL - 1960   Palindromes and Super Abilities 回文树水题,每次插入时统计数量即可. #include<bits/stdc++.h> using namespace std; #define eps 1e-9 #define For(i,a,b) for(int i=a;i<=b;i++) #define Fore(i,a,b) for(int i=a;i>=b;i--) #define lson l,mid,rt<<1 #d…
CA loves strings, especially loves the palindrome strings. One day he gets a string, he wants to know how many palindromic substrings in the substring S[l,r] . Attantion, each same palindromic substring can only be counted once. InputFirst line conta…
回文树 Palindromic Tree 嗯..回文树是个什么东西呢. 回文树(或者说是回文自动机)每个节点代表一个本质不同的回文串. 首先它类似字典树,每个节点有SIGMA个儿子,表示对应的字母. 其次它类似自动机,有一个fail指针,一个节点的fail指针指向这个回文串的最长回文后缀.比如说abbaabba的fail指向abba的最后一个a. 利用回文树,我们可以在线性(不太确定是线性还是\(nlogn\)?)的时间内求出所有本质不同的回文子串,以及以每个字母结尾的最长回文子串. 有一个定理…
Victor and String Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/262144 K (Java/Others) Total Submission(s): 163    Accepted Submission(s): 78 Problem Description Victor loves to play with string. He thinks a string is charming as the…
题目链接 \(Description\) 给定一棵\(Trie\).求\(Trie\)上所有回文串 长度乘以出现次数 的和.这里的回文串只能是从上到下的一条链. 节点数\(n\leq 2\times 10^6\),字符集为a,b,c,d. \(Solution\) 如果不是树,就是回文树模板.对于树,DFS \(x\)的每个儿子的时候都用在\(x\)处的\(las\)即可,也就是按深度存一个\(las\)数组,每次用\(las[dep-1]\)做\(las\)去插入即可.(也可以回溯的时候直接删…
回文树,也叫回文自动机,是2014年被西伯利亚民族发明的,其功能如下: 1.求前缀字符串中的本质不同的回文串种类 2.求每个本质不同回文串的个数 3.以下标i为结尾的回文串个数/种类 4.每个本质不同回文串包含的本质不同回文串种类 (本文参考自Palindromic Tree——回文树[处理一类回文串问题的强力工具],Palindromic Tree 回文自动机-回文树 解决回文串的神器) 下面介绍一些数组的意义 next[][]类似于字典树,指向当前字符串在两段同时加上一个字符 fail[]…
Palindromic Substring Time Limit: 10 Seconds      Memory Limit: 65536 KB In the kingdom of string, people like palindromic strings very much. They like only palindromic strings and dislike all other strings. There is a unified formula to calculate th…
Sample Input 6 1 a 1 b 2 a 2 c 3 4 8 1 a 2 a 2 a 1 a 3 1 b 3 4 Sample Output 4 5 4 5 11 题意:多组输入,开始字符串为空,支持4中操作: 1,在字符串首加字符: 2,在字符串尾加字符: 3,查询字符串不同本质的回文串个数: 4,查询回文串个数总和 思路:因为支持首尾加入,所以和常规的回文树有些不同. 参考了YYB的博客. 发现首尾互相影响,当且仅当整个字符串是回文串. 其他情况两头正常加即可. #include…