This question was teased during the competition yesterday. I couldn't think of the suffix, because the t of N ^ 2 didn't think about the suffix array ...... In addition, the people who solve the problem later said that they would use binary sets for binary classification, and then they would not ......
I read the answer just now ...... It turns out that N ^ 2 can also be used, and then ...... That's it!
# pragma comment (linker, "/Stack: 1024000000,1024000000 ") # include # include # include # include # include # include # include # include # include # define MEM (, b) memset (a, B, sizeof (A) # define lson I <1, L, mid # define rson I <1 | 1, Mid + 1, R # define llson j <1, L, mid # define rrson j <1 | 1, Mid + 1, R # define INF 0x7fffffff # define seed 13131 # define seed1 1313 # de Fine maxn 20005 typedef long ll; typedef unsigned long ull; using namespace STD; void Radix (int * STR, int * a, int * B, int N, int m) {static int count [maxn]; MEM (count, 0); For (INT I = 0; I = 0; I --) B [-- count [STR [A [I] = A [I];} void suffix (int * STR, int * Sa, int N, int m) // calculate the suffix array SA {static int rank [maxn], a [m AXN], B [maxn]; for (INT I = 0; I = n? 0: rank [J + (1 = I) sum ++; max = min = sa [J];} else {max = max (max, sa [J]); min = min (Min, sa [J]) ;}} printf ("% d \ n", sum); Return 0 ;}
acdream 1430 SETI suffix array + height group