.
SAIS真的好快啊,在UOJ能卡进第二页
推荐几个讲的比较好的博客
链接1
链接2
链接3
和一篇讲了各种后缀数组算法的论文
Code:
#pragma GCC optimize("O3")
#pragma G++ optimize("O3")
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define N 100010
using namespace std;
const int BufferSize = 1180000;
char buffer[BufferSize];
char *out_tail = buffer;
inline void putint(int x)
{
if (!x) *out_tail++ = '0';
else
{
register char s_pool[6], *s_tail = s_pool;
while (x != 0) *s_tail++ = x % 10 + '0', x /= 10;
while (s_tail-- != s_pool) *out_tail++ = *s_tail;
}
*out_tail++ = ' ';
}
char S[N]; int n,m;
int s[N<<1],t[N<<1],H[N],sa[N],r[N],p[N],c[N],w[N];
inline int trans(int n,const char* S){
int m=*max_element(S+1,S+1+n);
for(int i