CountSort + SA
#include<stdio.h>#include<stdlib.h>#include<string.h>#define MaxL 1048576int Build_Height(int);struct xy_change_rank{ int index, v; }Data[MaxL];char S[MaxL], base_rank[256], Mask[MaxL]; int s2[30]={1}, rank[MaxL], SA[MaxL], Queue[MaxL] = ...