就是后缀自动机的板子嘛..构造完自动机之后拓扑一下,记录size,对于size大于k的点和ans取max #include<iostream> #include<cstdio> #include<cstring> #include<map> using namespace std; const int N=100005; int n,m,a[N],cur=1,cnt=1; int read() { int r=0,f=1; char p=getchar();…
求重复k次的最长重复子串,解法见罗穗骞大神的后缀数组论文 ; var x,y,rank,sa,h,s,num,c:..maxn] of longint; n,time:longint; function max(x,y:longint):longint; begin if x>y then exit(x) else exit(y); end; function min(x,y:longint):longint; begin if x<y then exit(x) else exit(y); e…
题目链接 思路 先求出后缀数组,并且求出LCP.二分一下长度len.check的时候就是看有没有连续的k个后缀的LCP大于len.也就是判断是不是有连续的k-1个height大于len. 代码 #include<cstdio> #include<iostream> using namespace std; typedef long long ll; const int N = 20000+10; ll read() { ll x = 0,f = 1;char c = getchar…
1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 554 Solved: 346[Submit][Status][Discuss] Description The cows are having a picnic! Each of Farmer John's K (1 <= K <= 100) cows is grazing in one of N (1 <= N <…
有点类似背包 , 就是那样子搞... ------------------------------------------------------------------------------------ #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #define rep( i , n ) for( int i = 0 ; i < n ; ++i…
1650: [Usaco2006 Dec]River Hopscotch 跳石子 Time Limit: 5 Sec Memory Limit: 64 MB Description Every year the cows hold an event featuring a peculiar version of hopscotch that involves carefully jumping from rock to rock in a river. The excitement takes…