随笔分类 - 字符串处理——后缀自动机
摘要:题意:给定字符串S,然后M个字符串T。Q次询问,每次给出(L,R,l,r),问S[l,r]在L到R这些T字符串中,在哪个串出现最多,以及次数。 思路:把所有串建立SAM,然后可以通过倍增走到[l,r]在SAM上的位置p,然后在这个位置p上求,求的过程就是一个线段树求区间最值。 现在的关键是得到线段树
阅读全文
摘要:题意:给定字符串S; Q次询问,每次询问给出(L,R,T),让你在S[L,R]里面找一个字典序最小的子串,其字典序比T大。 没有则输出-1; 思路:比T字典序大,而且要求字典最小,显然就是在T的尾巴加一个很小的字符,如果不存在,则依次删去尾巴,直到“存在”。 而“存在”是指,前缀lim+一个字符‘x
阅读全文
摘要:题解见:http://ecustacm.cn/contest/11/announcements A #include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<=b;i++) using namespace std; const int maxn
阅读全文
摘要:有方程dp[i]=min(dp[i-1]+A,dp[j]+B);如果s[j+1,i]在s[i,j]中出现,所以我们就是要知道每个子串在s出现的第一个位置,这个可以hash实现或者sam,或者kmp实现。 pos[i][j]表示s[i,j]对应的sam的位置,occ[],表示第一次出现的位置。
阅读全文
摘要:You are given n strings ti. Each string has cost ci. Let's define the function of string , where ps, i is the number of occurrences of s in ti, |s| is
阅读全文
摘要:KMP,扩展KMP和Manacher就不写了,感觉没多大意思。 之前感觉后缀自动机简直可以解决一切,所以不怎么写后缀数组。 马拉车主要是通过对称中心解决问题,有的时候要通过回文串的边界解决问题,这个时候回文树就用到了,又好写,又强大。 之前整理过一篇后缀自动机的。感觉还要整理一下,顺便把回文树,后缀
阅读全文
摘要:You are given a string ss. You should answer nn queries. The ii-th query consists of integer kiki and string mimi. The answer for this query is the mi
阅读全文
摘要:The Little Elephant loves strings very much. He has an array a from n strings, consisting of lowercase English letters. Let's number the elements of t
阅读全文
摘要:Police headquarter is monitoring signal on different frequency levels. They have got two suspiciously encoded strings s1 and s2 from two different fre
阅读全文
摘要:问题: Amateur astronomers Tom and Bob try to find radio broadcasts of extraterrestrial civilizations in the air. Recently they received some strange sig
阅读全文
摘要:Beside other services, ACM helps companies to clearly state their “corporate identity”, which includes company logo but also other signs, like tradema
阅读全文
摘要:后缀家族已知成员 后缀树 后缀数组 后缀自动机 后缀仙人掌 后缀预言 后缀Splay ? 后缀树是后缀数组和后缀自动机的祖先? 功能还是比较强大的,在回文串或者字典序方面还是有用处。 而且现在已经有了线性的建树方法。 (但其实我也没用过后缀树。)下面对比后缀自动机和后缀数组 单个字符串问题 不等号是
阅读全文
摘要:Oimaster and sevenk love each other. 题意: 给定一些模板串,询问每个匹配串在多少个模板串里出现过。 思路: 后缀数组办法: 全部模板串连接在一起SA排序,SA数组附件的串里面去验证原串,还没写,我说不清楚,大概是后缀数组+RMQ处理。 后缀自动机办法: 1,广义
阅读全文
摘要:You may have wondered why most extraterrestrial life forms resemble humans, differing by superficial traits such as height, colour, wrinkles, ears, ey
阅读全文
摘要:问题: The little cat is majoring in physics in the capital of Byterland. A piece of sad news comes to him these days: his mother is getting ill. Being w
阅读全文
摘要:Given a string, we need to find the total number of its distinct substrings. Input T- number of test cases. T<=20;Each test case consists of one strin
阅读全文
摘要:A substring of a string T is defined as: T( i, k)= TiTi +1... Ti+k -1, 1≤ i≤ i+k-1≤| T|. Given two strings A, B and one integer K, we define S, a set
阅读全文
摘要:Once upon a time there was a famous actress. As you may expect, she played mostly Antique Comedies most of all. All the people loved her. But she was
阅读全文
摘要:Problem Description In middle school, teachers used to encourage us to pick up pretty sentences so that we could apply those sentences in our own arti
阅读全文
摘要:Problem Description 035 now faced a tough problem,his english teacher gives him a string,which consists with n lower case letter,he must figure out ho
阅读全文