随笔分类 - 字符串处理——回文树
摘要:题意:给定字符串Str,求出回文串集合为S,问S中的(a,b)满足a是b的子串的对数。 思路:开始和题解的思路差不多,维护当前后缀的每个串的最后出现位置,但是不知道怎么套“最小回文分割”,所以想到了树剖,但是树剖不好同时维护“最后出现的次数”,“查询左端点>=L”的位置数。 所以GG。 那么从图论的
阅读全文
摘要:KMP,扩展KMP和Manacher就不写了,感觉没多大意思。 之前感觉后缀自动机简直可以解决一切,所以不怎么写后缀数组。 马拉车主要是通过对称中心解决问题,有的时候要通过回文串的边界解决问题,这个时候回文树就用到了,又好写,又强大。 之前整理过一篇后缀自动机的。感觉还要整理一下,顺便把回文树,后缀
阅读全文
摘要:不知道写什么。。。
阅读全文
摘要: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]
阅读全文
摘要: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,查询字符串不同本质的回文
阅读全文
摘要:Sample Input aca aaaa Sample Output 3 15 题意: 多组输入,每次给定字符串S(|S|<1e5),求多少对不相交的回文串。 思路:可以用回文树求出以每个位置结尾的回文串数,那么累加得到前缀和; 倒着再做一遍得到每个位置为开头的回文串数,乘正向求出的前缀和即可。
阅读全文
摘要: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
阅读全文
摘要:A string is palindrome, if the string reads the same backward and forward. For example, strings like "a", "aa", "appa", "queryreuq" are all palindrome
阅读全文