Language: C++

#include<iostream>
#include<cstdio> 
#include<cstring> 
#include<iostream> 
#include<algorithm> 

using namespace std; 

#define LL long long

const LL N = 20000 + 100; 
LL sa[N],n;
LL t1[N], t2[N], c[N]; 
LL rank[N], height[N]; 
char ch[N]; 
void build_sa(LL s[], LL n, LL m) {
    LL p,  * x = t1,  * y = t2; 
    for (LL i = 0; i < m; i++)c[i] = 0; 
    for (LL i = 0; i < n; i++)c[x[i] = s[i]]++; 
    for (LL i = 1; i < m; i++)c[i] += c[i-1]; 
    for (LL i = n-1; i >= 0; i--)sa[--c[x[i]]] = i; 
    for (LL j = 1; j <= n; j <<= 1) {
        LL p = 0; 
        for (LL i = n - j; i < n; i++)y[p++] = i; 
        for (LL i = 0; i < n; i++)if (sa[i] >= j)y[p++] = sa[i] - j; 
        for (LL i = 0; i < m; i++)c[i] = 0; 
        for (LL i = 0; i < n; i++)c[x[y[i]]]++; 
        for (LL i = 1; i < m; i++)c[i] += c[i-1]; 
        for (LL i = n-1; i >= 0; i--)sa[--c[x[y[i]]]] = y[i]; 
        //根据sa和x数组计算新的x数组
        swap(x, y); 
        p = 1; x[sa[0]] = 0; 
        for (LL i = 1; i < n; i++)
            x[sa[i]] = y[sa[i-1]] == y[sa[i]] && y[sa[i-1] + j] == y[sa[i] + j]?p-1:p++; 
        if (p >= n)break; 
        m = p; //下次基数排序的最大值
}
}
void getHeight(LL s[], LL n) {
    LL k = 0; 
    for (LL i = 0; i <= n; i++)rank[sa[i]] = i; 
    for (LL i = 0; i < n; i++) {
        if (k)k--; 
        LL j = sa[rank[i]-1]; 
        while (s[i + k] == s[j + k])k++; 
        height[rank[i]] = k; 
    }
}
LL s[N]; 
bool check(LL n, LL len) {
    LL ma = sa[1], mi = sa[1]; 
    for (LL i = 2; i <= n; i++) {
        if (height[i] < len)ma = mi = sa[i]; 
        else {
            mi = min(mi, sa[i]); 
            ma = max(ma, sa[i]); 
            if (ma - mi > len)return true; 
        }
    }
    return false; 
}

int main() { 
    scanf("%lld",  & n); 
    scanf("%s", ch); 
        for (int i = 0; i < n; i++)s[i] = ch[i] - '0'; 
        for (int i = n-1; i > 0; i--)s[i] = s[i] - s[i-1] + 90; 
        n--; 
        for (int i = 0; i < n; i++)s[i] = s[i + 1]; 
        s[n] = 0; 
        build_sa(s, n + 1, 200); 
        getHeight(s, n); 
        LL ans = -1; 
        LL l = 1, r = n/2; 
        while (l <= r) {
            LL mid = (l + r)/2; 
            if (check(n, mid))ans = mid, l = mid + 1; 
            else r = mid-1; 
        }
        if (ans == 0)printf("0\n"); 
        else printf("%lld\n", ans + 1); 
        //system("pause"); 
    return 0; 
}

Compiler output:
a.cc: In function 'void getHeight(long long int*, long long int)':
a.cc:41:32: error: reference to 'rank' is ambiguous
   41 |     for (LL i = 0; i <= n; i++)rank[sa[i]] = i;
      |                                ^~~~
In file included from /usr/include/c++/14/bits/move.h:37,
                 from /usr/include/c++/14/bits/exception_ptr.h:41,
                 from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/ios:41,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:14:4: note:                 'long long int rank [20100]'
   14 | LL rank[N], height[N];
      |    ^~~~
a.cc:44:19: error: reference to 'rank' is ambiguous
   44 |         LL j = sa[rank[i]-1];
      |                   ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:14:4: note:                 'long long int rank [20100]'
   14 | LL rank[N], height[N];
      |    ^~~~
a.cc:46:16: error: reference to 'rank' is ambiguous
   46 |         height[rank[i]] = k;
      |                ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:14:4: note:                 'long long int rank [20100]'
   14 | LL rank[N], height[N];
      |    ^~~~