A string s is called an (k,l)-repeat if s is obtained by concatenating k>=1 times some seed string t with length l>=1. For example, the string s = abaabaabaaba is a (4,3)-repeat with t = aba as its seed string. That is, the seed string t is 3 charac…
题意:UVU形式的串的个数,V的长度规定,U要一样,位置不同即为不同字串 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=&problem=1770 题解:一开始理解错题意,以为是abcxxxcba(xxx为v),开心地打了后缀数组后发现哎样例不对丫.. UVA的意思是abcxxxabc(xxx为v). 类似poj3693,我们暴…
思路: 论文题 后缀数组&RMQ 有一些题解写得很繁 //By SiriusRen #include <cmath> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; #define N 100050 int n,cases,cntA[N],cntB[N],A[N],B[N],rk[N],sa[N],tsa[N],ht[N],f[N][18],…
string string string Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 608    Accepted Submission(s): 167 Problem Description Uncle Mao is a wonderful ACMER. One day he met an easy problem, but U…
题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5008 Description In this problem, you are given a string s and q queries. For each query, you should answer that when all distinct substrings of string s were sorted lexicographically, which one is…
题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5853 Description Jong Hyok loves strings. One day he gives a problem to his friend you. He writes down n strings Pi in front of you, and asks m questions. For i-th question, there is a string Qi. We…
题目链接 https://codeforces.com/contest/1063/problem/F 题解 虽然本题有时间复杂度较高但非常好写的做法...... 首先,若答案为 \(k\),则一定存在一种最优方案,使得对于任意 \(i \in [1, k)\),有 \(|t_i| = |t_{i + 1}| + 1\),换句话说,第 \(i + 1\) 个字符串可以通过第 \(i\) 个字符串删掉首字符或尾字符得到.其正确性显然. 这样,我们可以记录 \(f_i\) 表示串 \(s\) 从 \(…
Codeforces 题面传送门 & 洛谷题面传送门 神仙题,做了我整整 2.5h,写篇题解纪念下逝去的中午 后排膜拜 1 年前就独立切掉此题的 ymx,我在 2021 年的第 5270 个小时 A 掉此题,而 ymx 在 2020 年的第 5270 就已经 A 掉了此题 %%%%%% 首先注意到一件事情,就是如果存在一个长度为 \(k\) 的 Journey,那么必然存在一个长度为 \(k\) 的 Journey,满足相邻两个字符串长度的差刚好为 \(1\)(方便起见,在后文中我们及其为 Co…
题意:让你求一个串中连续重复次数最多的串(不重叠),如果重复的次数一样多的话就输出字典序小的那一串. 分析:有一道比这个简单一些的题spoj 687, 假设一个长度为l的子串重复出现两次,那么它必然会包含s[0].s[l].s[l*2]...之中的相邻的两个.不难看出,该重复子串必然会包含s[0..l]或s[l..l*2]或s[l*2..l*3]....所以,我们可以枚举一个i,对于每个i*l的位置,利用后缀数组可以求出s[i*l..(i+1)*l]向后延伸的长度k.k/l+1即i*l..(i+…
思路: 求一发后缀数组,求个LCP 就好了 注意数字有可能不只一位 (样例2) //By SiriusRen #include <bits/stdc++.h> using namespace std; ; char s[N]; ]; int n,t,base[N],l[N],r[N]; void SA(){ ;i<=;i++)cntA[i]=; ;i<=n;i++)cntA[s[i]]++; ;i<=;i++)cntA[i]+=cntA[i-]; for(int i=n;i;…