Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
//#pragma comment(linker, "/STACK:1024000000,1024000000")

using namespace std;

#define ll long long
#define SZ(x) ((int)(x).size()) 
#define ALL(v) (v).begin(), (v).end()
#define foreach(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define reveach(i, v) for (__typeof((v).rbegin()) i = (v).rbegin(); i != (v).rend(); ++ i) 
#define REP(i,a,n) for ( int i=a; i<int(n); i++ )
#define FOR(i,a,n) for ( int i=n-1; i>= int(a);i-- )
#define lson rt<<1, L, m
#define rson rt<<1|1, m, R
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define fi first
#define se second
#define CLR(a, b) memset(a, b, sizeof(a))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

const int MAXN=500000 + 7;
const int MOD = 1e9 + 7;
int t1[MAXN],t2[MAXN],c[MAXN];//求SA数组需要的中间变量,不需要赋值 //待排序的字符串放在s数组中,从s[0]到s[n-1],长度为n,且最大值小于m, //除s[n-1]外的所有s[i]都大于0,r[n-1]=0 //函数结束以后结果放在sa数组中
bool cmp(int *r,int a,int b,int l)
{
    return r[a] == r[b] && r[a+l] == r[b+l]; 
}
void da(int str[],int sa[],int rank[],int height[],int n,int m) {
    n++;
    int i, j, p, *x = t1, *y = t2; //第一轮基数排序,如果s的最大值很大,可改为快速排序
    for(i = 0;i < m;i++)c[i] = 0;
    for(i = 0;i < n;i++)c[x[i] = str[i]]++; for(i = 1;i < m;i++)c[i] += c[i-1];
    for(i = n-1;i >= 0;i--)sa[--c[x[i]]] = i; for(j = 1;j <= n; j <<= 1)
    {
        p = 0;
        //直接利用sa数组排序第二关键字
        for(i = n-j; i < n; i++)y[p++] = i;//后面的j个数第二关键字为空的最小
        for(i = 0; i < n; i++)if(sa[i] >= j)y[p++] = sa[i] - j; //这样数组y保存的就是按照第二关键字排序的结果
        //基数排序第一关键字
        for(i = 0; i < m; i++)c[i] = 0;
        for(i = 0; i < n; i++)c[x[y[i]]]++;
        for(i = 1; i < m;i++)c[i] += c[i-1];
        for(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(i = 1;i < n;i++)
            x[sa[i]] = cmp(y,sa[i-1],sa[i],j)?p-1:p++; if(p >= n)break;
        m = p;//下次基数排序的最大值
    }
    int k = 0; n--;
    for(i = 0;i <= n;i++)rank[sa[i]] = i; for(i = 0;i < n;i++)
    {
        if(k)k--;
        j = sa[rank[i]-1]; while(str[i+k] == str[j+k])k++; height[rank[i]] = k;
    } 
}
int rank[MAXN],height[MAXN];
int RMQ[MAXN];
int mm[MAXN];
int best[20][MAXN];
void initRMQ(int n) {
    mm[0]=-1;
    for(int i=1;i<=n;i++)
        mm[i]=((i&(i-1))==0)?mm[i-1]+1:mm[i-1]; for(int i=1;i<=n;i++)best[0][i]=i;
    for(int i=1;i<=mm[n];i++)
        for(int j=1;j+(1<<i)-1<=n;j++) {
            int a=best[i-1][j];
            int b=best[i-1][j+(1<<(i-1))]; if(RMQ[a]<RMQ[b])best[i][j]=a; else best[i][j]=b;
        }
}
int askRMQ(int a,int b) {
    if(a > b) swap(b);
    int t;
    t=mm[b-a+1];
    b-=(1<<t)-1; a=best[t][a];b=best[t][b]; return RMQ[a]<RMQ[b]?a:b;
}
int lcp(int a,int b) {
    a= :: rank[a];b= :: rank[b]; if(a>b)swap(a,b);
    return height[askRMQ(a+1,b)];
}
char str[MAXN];
int r[MAXN];
int sa[MAXN];
int n;
bool equ(){
    if(n == 1) return true;
    REP(i, 1, n) if(r[i] != r[i - 1]) return false;
    return true;
}
bool one(){
    int len = n + 1;
    REP(i, :: rank[0] + 1, n + 1){
        Min(len, height[i]);
        if(len == n - sa[i] && len % sa[i] == 0){
            return false;
        }
    }
    len = n + 1;
    FOR(i, 2, :: rank[0] + 1){
        Min(len, height[i]);
        if(len == n - sa[i - 1] && len % sa[i - 1] == 0){
            return false;
        }
    }
    return true;
}
int pre[MAXN], suf[MAXN];
int main(){
#ifdef ac
    freopen("in.txt","r",stdin);
#endif
    //freopen("out.txt","w",stdout);
    scanf("%s", str);
    n = strlen(str);
    REP(i, 0, n) r[i] = str[i];
    r[n] = 0;
    da(r, sa, :: rank, height, n, 128);
    REP(i, 1, n + 1) RMQ[i] = height[i];
    initRMQ(n);
    if(equ()){
        printf("%d\n%d\n", n, 1);
        return 0;
    }
    //REP(i, 1, n + 1) printf("i = %d, sa[i] = %d\n", i, sa[i]);
    if(one()){
        puts("1\n1");
        return 0;
    }
    puts("2");
    pre[1] = 1;
    REP(len, 2, n){
        
    }
    return 0;
}


Compiler output:
a.cc: In function 'int askRMQ(int, int)':
a.cc:88:19: error: no matching function for call to 'swap(int&)'
   88 |     if(a > b) swap(b);
      |               ~~~~^~~
In file included 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/bits/move.h:226:5: note: candidate: 'template<class _Tp> std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&)'
  226 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/include/c++/14/bits/move.h:226:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/move.h:250:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> std::__enable_if_t<((bool)std::__is_swappable<_Tp>::value)> std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])'
  250 |     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
      |     ^~~~
/usr/include/c++/14/bits/move.h:250:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44:
/usr/include/c++/14/bits/stl_pair.h:1089:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)'
 1089 |     swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
      |     ^~~~
/usr/include/c++/14/bits/stl_pair.h:1089:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_pair.h:1106:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<(! std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value)>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' (deleted)
 1106 |     swap(pair<_T1, _T2>&, pair<_T1, _T2>&) = delete;
      |     ^~~~
/usr/include/c++/14/bits/stl_pair.h:1106:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/14/string:54:
/usr/include/c++/14/bits/basic_string.h:4039:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> void std::swap(__cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 4039 |     swap(basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~
/usr/include/c++/14/bits/basic_string.h:4039:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
                 from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2805:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<std::__and_<std::__is_swappable<_Elements>...>::value>::type std::swap(tuple<_UTypes ...>&, tuple<_UTypes ...>&)'
 2805 |     swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y)
      |     ^~~~
/usr/include/c++/14/tuple:2805:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/tuple:2823:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<(! std::__and_<std::__is_swappable<_Elements>...>::value)>::type std::swap(tuple<_UTypes ...>&, tuple<_UTypes ...>&)' (deleted)
 2823 |     swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete;
      |     ^~~~
/usr/include/c++/14/tuple:2823:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:8:
/usr/include/c++/14/bits/stl_vector.h:2122:5: note: candidate: 'template<class _Tp, class _Alloc> void std::swap(vector<_Tp, _Alloc>&, vector<_Tp, _Alloc>&)'
 2122 |     swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y)
      |     ^~~~
/usr/include/c++/14/bits/stl_vector.h:2122:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/14/deque:66,
                 from /usr/include/c++/14/queue:62,
                 from a.cc:9:
/usr/include/c++/14/bits/stl_deque.h:2370:5: note: candidate: 'template<class _Tp, class _Alloc> void std::swap(deque<_Tp, _Alloc>&, deque<_Tp, _Alloc>&)'
 2370 |     swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y)
      |     ^~~~
/usr/include/c++/14/bits/stl_deque.h:2370:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/14/queue:66:
/usr/include/c++/14/bits/stl_queue.h:445:5: note: candidate: 'template<class _Tp, class _Seq> typename std::enable_if<std::__is_swappable<_T2>::value>::type std::swap(queue<_Tp, _Seq>&, queue<_Tp, _Seq>&)'
  445 |     swap(queue<_Tp, _Seq>& __x, queue<_Tp, _Seq>& __y)
      |     ^~~~
/usr/include/c++/14/bits/stl_queue.h:445:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_queue.h:834:5: note: candidate: 'template<class _Tp, class _Sequence, class _Compare> typename std::enable_if<std::__and_<std::__is_swappable<_T2>, std::__is_swappable<_Compare> >::value>::type std::swap(priority_queue<_Tp, _Sequence, _Compare>&, priority_queue<_Tp, _Sequence, _Compare>&)'
  834 |     swap(priority_queue<_Tp, _Sequence, _Compare>& __x,
      |     ^~~~
/usr/include/c++/14/bits/stl_queue.h:834:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/14/stack:63,
                 from a.cc:10:
/usr/include/c++/14/bits/stl_stack.h:421:5: note: candidate: 'template<class _Tp, class _Seq> typename std::enable_if<std::__is_swappable<_T2>::value>::type std::swap(stack<_Tp, _Seq>&, stack<_Tp, _Seq>&)'
  421 |     swap(stack<_Tp, _Seq>& __x, stack<_Tp, _Seq>& __y)
      |     ^~~~
/usr/include/c++/14/bits/stl_stack.h:421:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/14/set:62,
                 from a.cc:11:
/usr/include/c++/14/bits/stl_tree.h:1675:5: note: candidate: 'template<class _Key, class _Val, class _KeyOfValue, class _Compare, class _Alloc> void std::swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&, _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&)'
 1675 |     swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
      |     ^~~~
/usr/include/c++/14/bits/stl_tree.h:1675:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/14/set:63:
/usr/include/c++/14/bits/stl_set.h:1061:5: note: candidate: 'template<class _Key, class _Compare, class _Alloc> void std::swap(set<_Key, _Compare, _Allocator>&, set<_Key, _Compare, _Allocator>&)'
 1061 |     swap(set<_Key, _Compare, _Alloc>& __x, set<_Key, _Compare, _Alloc>& __y)
      |     ^~~~
/usr/include/c++/14/bits/stl_set.h:1061:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/14/set:64:
/usr/include/c++/14/bits/stl_multiset.h:1047:5: note: candidate: 'template<class _Key, class _Compare, class _Alloc> void std::swap(multiset<_Key, _Compare, _Allocator>&, multiset<_Key, _Compare, _Allocator>&)'
 1047 |     swap(multiset<_Key, _Compare, _Alloc>& __x,
      |     ^~~~
/usr/include/c++/14/bits/stl_multiset.h:1047:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/14/map:63,
                 from a.cc:12:
/usr/include/c++/14/bits/stl_map.h:1586:5: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> void std::swap(map<_Key, _Tp, _Compare, _Allocator>&, map<_Key, _Tp, _Compare, _Allocator>&)'
 1586 |     swap(map<_Key, _Tp, _Compare, _Alloc>& __x,
      |     ^~~~
/usr/include/c++/14/bits/stl_map.h:1586:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/14/map:64:
/usr/include/c++/14/bits/stl_multimap.h:1208:5: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> void std::swap(multimap<_Key, _Tp, _Compare, _Allocator>&, multimap<_Key, _Tp, _Compare, _Allocator>&)'
 1208 |     swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x,
      |     ^~~~
/usr/include/c++/14/bits/stl_multimap.h:1208:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/exception_ptr.h:229:5: note: candidate: 'void std::__exception_ptr::swap(exception_ptr&, exception_ptr&)'
  229 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~
/usr/include/c++/14/bits/exception_ptr.h:229:5: note:   candidate expects 2 arguments, 1 provided