# include & lt; Bits/stdc++. H>
using namespace std;
E6 const int N=2 + 5;
Char STR [N].
Int s [N], sa [N], fairly rk [N], [N], c _x [N], _y [N].
Int n, m;
/*
Void tree () {
for (int i=0; i <=m; [I] i++) c=0;
For (int I=1; i <=n; I++) c [x] [I] + +;
For (int I=1; i <=m; I++) [I] + c=c [I - 1);
For (int I=n; I & gt;=1; I -) sa [c [x/y [I]]] -]=y [I];
}
*/
Void SA () {
Int * x=_x;//use array is timeout, use AC pointer?
Int * y=_y;
M=n;
for (int i=0; i <=m; [I] i++) c=0;
For (int I=1; i <=n; I++) c [I] [x=s [I]] + +;
For (int I=1; i <=m; I++) [I] + c=c [I - 1);
For (int I=n; I & gt;=1; I -) sa [x] [I] - [c]=I;
//for (int I=1; i<=n; I++) x=s [I] [I], [I] y=I;
//tree ();
For (int k=1, p; K & lt;=n; K & lt; <=1, m=p) {
P=0;
For (int I=n; I & gt; N - k; I -) [+ + y p]=I;
For (int I=1; i <=n; I++)
If (sa [I] & gt; K)
Y [+ + p]=sa [I] - k;
for (int i=0; i <=m; [I] i++) c=0;
For (int I=1; i <=n; I++) c [x] [I] + +;
For (int I=1; i <=m; I++) [I] + c=c [I - 1);
For (int I=n; I & gt;=1; I -) sa [c [x/y [I]]] -]=y [I];
P=y/sa [1]=1;
For (int I=2, a, b; i <=n; I++) {
A=(sa [I] + k & gt; n ? 1: x [sa + k] [I]);
B=(sa [I - 1) + k & gt; n ? 1: x [sa] [I - 1) + k);
Y [sa [I]]=(x==[sa [I]] x [sa [I - 1]] & amp; & A==b)? P: + + p;
}
Swap (x, y);
}
}
Int main () {
While (~ the scanf (" % d ", & amp; N)) {
The scanf (" % s ", STR + 1);
Int pos [2]={1, 1};
For (int I=n; I & gt;=1; I -) {
If (~ pos [STR [I] - 'a'])
S=n - [I] (pos [STR [I] - 'a'] - I);
The else
S [I]=0;
Pos [STR [I] - 'a']=I;
}
SA ();
For (int I=1; i <=n; I++)
Printf (" % d ", sa [I]);
printf("\n");
}
return 0;
}
Here is the inside of the SA () int * x, int * y, if directly on the outside of the array x [N], [N] y will timeout, what circumstance, TLE one day,
CodePudding user response:
If use arrays, don't know where you array is defined, if it is on the stack, more than stack space size, using a pointer is ac is what mean?CodePudding user response: