hiho week 123 register

Ended

Participants:149

Verdict:Accepted
Score:100 / 100
Submitted:2016-11-12 14:56:23

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
const int N = 100000+50;
int cmp(int *r,int a,int b,int l)
{
    return (r[a]==r[b]) && (r[a+l]==r[b+l]);
}
// ,
// ,,r[n]=0()
/*
    DA(aa,sa,n+1,200);
    calheight(aa,sa,n);
*/
int wa[N],wb[N],ws[N],wv[N];
int Rank[N];//isa[]
int height[N];//sa[i]sa[i-1]LCP
int sa[N];//sa[i]i
void DA(int *r,int *sa,int n,int m)  //NN1CMP
{
    int i,j,p,*x=wa,*y=wb,*t;
    for(i=0; i<m; i++) ws[i]=0;
    for(i=0; i<n; i++) ws[x[i]=r[i]]++;
    for(i=1; i<m; i++) ws[i]+=ws[i-1];
    for(i=n-1; i>=0; i--) sa[--ws[x[i]]]=i; //1
    for(j=1,p=1; p<n; j*=2,m=p) //JSA2*JSA
    {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX