是真的只是模板了,暂时没办法完全理解代码实现。
Distinct Substrings
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#define LL long long
using namespace std;
const int maxn = 1e5;
char str[maxn + 5], s[maxn + 5];
int n, m, rk[maxn + 5], tp[maxn + 5], tax[maxn + 5], sa[maxn + 5], height[maxn + 5];
//rk为第i个后缀的排名,sa为排名为i的后缀,tax用于sort辅助排序,tp为rk的辅助数组,记录第二关键字的排名为i的后缀,height为lcp
void Sort(){//更新sa
for(int i = 0; i <= m; i++) tax[i] = 0;
for(int i = 1; i <= n; i++