Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;


class RollingHash {
    ll base1;
    ll base2;
    ll mod1;
    ll mod2;
    vector<ll> hash1, hash2, pow1, pow2;
public:
    RollingHash() : base1(1009), base2(2009), mod1(1000000007), mod2(1000000009) {
    }

    void init(const string &S) {
        int n = (int) S.size();

        hash1.assign(n + 1, 0);
        hash2.assign(n + 1, 0);
        pow1.assign(n + 1, 1);
        pow2.assign(n + 1, 1);

        for (int i = 0; i < n; ++i) {
            hash1[i + 1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i + 1] = (hash2[i] * base2 + S[i]) % mod2;
            pow1[i + 1] = (pow1[i] * base1) % mod1;
            pow2[i + 1] = (pow2[i] * base2) % mod2;
        }
    }

    inline pair<ll, ll> get(int l, int r) const {
        ll h1 = hash1[r] - hash1[l] * pow1[r - l] % mod1;
        if (h1 < 0) h1 += mod1;
        ll h2 = hash2[r] - hash2[l] * pow2[r - l] % mod2;
        if (h2 < 0) h2 += mod2;
        return make_pair(h1, h2);
    }

    inline int getLCP(int a, int b) const {
        int len = min((int) hash1.size() - a, (int) hash1.size() - b);
        int low = 0;
        int high = len;
        while (high - low > 1) {
            int mid = (high + low) >> 1;
            if (get(a, a + mid) != get(b, b + mid)) {
                high = mid;
            } else {
                low = mid;
            }
        }
        return low;
    }
};

int main() {
    int N;
    string S;
    cin >> N >> S;
    RollingHash rollingHash;
    rollingHash.init(S);

    int res = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            int lcp = rollingHash.getLCP(i, j);
            lcp = min(lcp, j-i);
            res = max(res, lcp);
        }
    }

    cout << res << endl;
}


Compiler output:
a.cc:9:5: error: 'll' does not name a type
    9 |     ll base1;
      |     ^~
a.cc:10:5: error: 'll' does not name a type
   10 |     ll base2;
      |     ^~
a.cc:11:5: error: 'll' does not name a type
   11 |     ll mod1;
      |     ^~
a.cc:12:5: error: 'll' does not name a type
   12 |     ll mod2;
      |     ^~
a.cc:13:12: error: 'll' was not declared in this scope
   13 |     vector<ll> hash1, hash2, pow1, pow2;
      |            ^~
a.cc:13:14: error: template argument 1 is invalid
   13 |     vector<ll> hash1, hash2, pow1, pow2;
      |              ^
a.cc:13:14: error: template argument 2 is invalid
a.cc:34:17: error: 'll' was not declared in this scope
   34 |     inline pair<ll, ll> get(int l, int r) const {
      |                 ^~
a.cc:34:21: error: 'll' was not declared in this scope
   34 |     inline pair<ll, ll> get(int l, int r) const {
      |                     ^~
a.cc:34:23: error: template argument 1 is invalid
   34 |     inline pair<ll, ll> get(int l, int r) const {
      |                       ^
a.cc:34:23: error: template argument 2 is invalid
a.cc: In constructor 'RollingHash::RollingHash()':
a.cc:15:21: error: class 'RollingHash' does not have any field named 'base1'
   15 |     RollingHash() : base1(1009), base2(2009), mod1(1000000007), mod2(1000000009) {
      |                     ^~~~~
a.cc:15:34: error: class 'RollingHash' does not have any field named 'base2'
   15 |     RollingHash() : base1(1009), base2(2009), mod1(1000000007), mod2(1000000009) {
      |                                  ^~~~~
a.cc:15:47: error: class 'RollingHash' does not have any field named 'mod1'
   15 |     RollingHash() : base1(1009), base2(2009), mod1(1000000007), mod2(1000000009) {
      |                                               ^~~~
a.cc:15:65: error: class 'RollingHash' does not have any field named 'mod2'
   15 |     RollingHash() : base1(1009), base2(2009), mod1(1000000007), mod2(1000000009) {
      |                                                                 ^~~~
a.cc: In member function 'void RollingHash::init(const std::string&)':
a.cc:21:15: error: request for member 'assign' in '((RollingHash*)this)->RollingHash::hash1', which is of non-class type 'int'
   21 |         hash1.assign(n + 1, 0);
      |               ^~~~~~
a.cc:22:15: error: request for member 'assign' in '((RollingHash*)this)->RollingHash::hash2', which is of non-class type 'int'
   22 |         hash2.assign(n + 1, 0);
      |               ^~~~~~
a.cc:23:14: error: request for member 'assign' in '((RollingHash*)this)->RollingHash::pow1', which is of non-class type 'int'
   23 |         pow1.assign(n + 1, 1);
      |              ^~~~~~
a.cc:24:14: error: request for member 'assign' in '((RollingHash*)this)->RollingHash::pow2', which is of non-class type 'int'
   24 |         pow2.assign(n + 1, 1);
      |              ^~~~~~
a.cc:27:18: error: invalid types 'int[int]' for array subscript
   27 |             hash1[i + 1] = (hash1[i] * base1 + S[i]) % mod1;
      |                  ^
a.cc:27:34: error: invalid types 'int[int]' for array subscript
   27 |             hash1[i + 1] = (hash1[i] * base1 + S[i]) % mod1;
      |                                  ^
a.cc:27:40: error: 'base1' was not declared in this scope
   27 |             hash1[i + 1] = (hash1[i] * base1 + S[i]) % mod1;
      |                                        ^~~~~
a.cc:27:56: error: 'mod1' was not declared in this scope
   27 |             hash1[i + 1] = (hash1[i] * base1 + S[i]) % mod1;
      |                                                        ^~~~
a.cc:28:18: error: invalid types 'int[int]' for array subscript
   28 |             hash2[i + 1] = (hash2[i] * base2 + S[i]) % mod2;
      |                  ^
a.cc:28:34: error: invalid types 'int[int]' for array subscript
   28 |             hash2[i + 1] = (hash2[i] * base2 + S[i]) % mod2;
      |                                  ^
a.cc:28:40: error: 'base2' was not declared in this scope
   28 |             hash2[i + 1] = (hash2[i] * base2 + S[i]) % mod2;
      |                                        ^~~~~
a.cc:28:56: error: 'mod2' was not declared in this scope
   28 |             hash2[i + 1] = (hash2[i] * base2 + S[i]) % mod2;
      |                                                        ^~~~
a.cc:29:17: error: invalid types 'int[int]' for array subscript
   29 |             pow1[i + 1] = (pow1[i] * base1) % mod1;
      |                 ^
a.cc:29:32: error: invalid types 'int[int]' for array subscript
   29 |             pow1[i + 1] = (pow1[i] * base1) % mod1;
      |                                ^
a.cc:30:17: error: invalid types 'int[int]' for array subscript
   30 |             pow2[i + 1] = (pow2[i] * base2) % mod2;
      |                 ^
a.cc:30:32: error: invalid types 'int[int]' for array subscript
   30 |             pow2[i + 1] = (pow2[i] * base2) % mod2;
      |                                ^
a.cc: In member function 'int RollingHash::get(int, int) const':
a.cc:35:9: error: 'll' was not declared in this scope; did you mean 'l'?
   35 |         ll h1 = hash1[r] - hash1[l] * pow1[r - l] % mod1;
      |         ^~
      |         l
a.cc:36:13: error: 'h1' was not declared in this scope
   36 |         if (h1 < 0) h1 += mod1;
      |             ^~
a.cc:36:27: error: 'mod1' was not declared in this scope
   36 |         if (h1 < 0) h1 += mod1;
      |                           ^~~~
a.cc:37:12: error: expected ';' before 'h2'
   37 |         ll h2 = hash2[r] - hash2[l] * pow2[r - l] % mod2;
      |            ^~
a.cc:38:13: error: 'h2' was not declared in this scope
   38 |         if (h2 < 0) h2 += mod2;
      |             ^~
a.cc:38:27: error: 'mod2' was not declared in this scope
   38 |         if (h2 < 0) h2 += mod2;
      |                           ^~~~
a.cc:39:26: error: 'h1' was not declared in this scope
   39 |         return make_pair(h1, h2);
      |                          ^~
a.cc:39:30: error: 'h2' was not declared in this scope
   39 |         return make_pair(h1, h2);
      |                              ^~
a.cc: In member function 'int RollingHash::getLCP(int, int) const':
a.cc:43:35: error: request for member 'size' in '((const RollingHash*)this)->RollingHash::hash1', which is of non-class type 'const int'
   43 |         int len = min((int) hash1.size() - a, (int) hash1.size() - b);
      |                                   ^~~~
a.cc:43:59: error: request for member 'size' in '((const RollingHash*)this)->RollingHash::hash1', which is of non-class type 'const int'
   43 |         int len = min((int) hash1.size() - a, (int) hash1.size() - b);
      |                                                           ^~~~