后缀数组#include#include#includeusing namespace std;#define MAXN 20010int n,newn,k,r[20010],rr[20010];int sa[20010];int wa            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2023-09-15 09:35:11
                            
                                32阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            后缀数组+单调队列注意:后缀数组的所有后缀中包括空串,因此有strlen(s)+1个后缀。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define N 20005struct Elem{ int pos, value; Elem() {} Elem(int pp, int vv): pos(pp), value(vv) {}}q[N];int n, m;int s[N];// N >            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2012-07-05 13:52:00
                            
                                20阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            3261: 最大异或和 Description 给定一个非负整数序列 {a},初始长度为 N。 有 M个操作,有以下两种操作类型: 1 、A x:添加操作,表示在序列末尾添加一个数 x,序列的长度 N+1。2 、Q l r x:询问操作,你需要找到一个位置 p,满足 l<=p<=r,使得: a[p]            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2017-03-24 18:24:00
                            
                                59阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            xor有一个很重要的性质就是A xor B xor B=A所以这道题求[l,r]中p,使a[p] xor a[p+1] xor ... xor a[N] xor x 最大就是=最大化a[1] xor ……a[n] xor x xor a[1] xor a[2] xor ……a[p-1]令b[i]=a[1] xor a[2] xor ……a[i]则最大化b[p] xor b[n] xor X p∈[            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2014-12-31 22:03:00
                            
                                39阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            题意:一个长度为n的串,要求最长的子串的长度且这个子串的出现次数不少于k次。(1#include using namespace std;const int N=20015;void sort(int *x, int *y, int *sa...            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2021-08-11 12:01:21
                            
                                114阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            POJ_3261
    这个题目和POJ_1743差不多,但需要求的是重复至少K次的子串。
    我们可以通过二分子串的长度k来做,这时就将题目变成了是否存在重复次数至少为K次且长度不小k的字符串。首先我们可以把相邻的所有不小于k的height[]看成一组,这组内有多少个字符串,就相当于有多少个长度至少为k的重复的子串。
    之所以可以这么做,是因为排名第i的字符串和排名第j的字符串的最长            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2012-02-03 18:35:00
                            
                                28阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            二分+后缀数组#include #include #include #include using namespace std;const int maxn=2e4+509;int *rank,height[maxn],sa[maxn];int r[maxn];inline bool cmp(int *r,int a,int b,int l){ return r[a]==r[b]&&r[a+l]==r[b+l];}void da(int *r,int n,int m){ int wx[maxn],wy[maxn],cnt[maxn]; int i,l,p,*x=wx,*y=wy.            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2013-08-07 18:36:00
                            
                                201阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            Description
Farmer John has noticed that the quality of milk given by his cows            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2022-11-09 18:26:14
                            
                                57阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            http://poj.org/problem?id=3261先把序            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2022-06-16 01:00:18
                            
                                53阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            1.题目链接。题目大意:给定一个字符串,求一个字串,这个字串在母串中出现了K次并且长度最长。输出这个最长的长度。2.应该算是后缀数组的经典题目了            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2022-07-01 10:39:11
                            
                                52阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            http://poj.org/problem?id=3261 题意: 求可重复的最长出现k次子串 后缀数组求出height后分组 从大到小每句长度,并查集合并            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2021-08-05 10:49:15
                            
                                23阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            题意:给出一个长度为n的数字序列,问可重叠的最长重复子串出现至少K次的长度。 题解:二分出长度x,判断连续height[i] >= x的情况如果出现K-1次就可以判断这个长度是成立的。#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int N = 20005;int wa[N            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2023-06-29 00:14:01
                            
                                24阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            Milk PatternsTime Limit: 5000msMemory Limit: 65536KBThis problem will be judged onPKU. Original ID:326164-bit integer IO format:%lld Java class name:M...            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2015-07-09 20:39:00
                            
                                48阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            【链接】h在这里写链接【题意】给你一个长度为n的序列。问你能不能在其中找到一个最长的子串。 这个子串至少出现了k次.【题解】长度越长,就越不可能出现k次后缀数组+二分。N最大为20000;每个数字在0到1e5之间防止出错,把那个数字都加上1就好(因为N比每个数字的大小来的小,所以需要把N也开到...            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2017-10-04 18:44:00
                            
                                46阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            
                                Sightseeing CowsSightseeing CowsDescriptionFarmer John has decided to reward his cows for their hard work by taking them on a tour of the big city! The cows must decid            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2023-07-17 16:08:29
                            
                                116阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            题目传送门题意:对一个字符串求一个最长的子串使得它至少出现k次额,因为这个题目呢,他的字符集非常大(100W)所以直接用SAM是不行了,我们考虑用离散化+SA,让后就可以分块rmq了当然这样很麻烦,我们还是用SAM,但是儿子集合用map来存,这样空间就是O(n)的,时...            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2017-11-27 21:07:00
                            
                                54阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            题目传送门题意:对一个字符串求一个最长的子串使得它至少出现k次额,因为这个题目呢,他的字符集非常大(100W)所以直接用SAM是不行了,我们考虑用离散化+SA,让后就可以分块rmq了当然这样很麻烦,我们还是用SAM,但是儿子集合用map来存,这样空间就是O(n)的,时间多了一个log#pragma ...            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2017-11-27 21:06:00
                            
                                52阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            Milk Patterns Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 17196 Accepted: 7612 Case Time Limit: 2000MS Description Farmer John has noti            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2021-12-31 10:55:54
                            
                                44阅读