This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define nl "\n"
#define nf endl
#define ll long long
#define pb push_back
#define _ << ' ' <<
#define INF (ll)1e18
#define mod 998244353
#define maxn 100010
ll i, i1, j, k, k1, t, n, m, res, flag[10], a, b;
ll l, r, f[36];
array<ll, 3> rs;
string s;
array<ll, 3> mxx(array<ll, 3> a, array<ll, 3> b) {
    if (a[0] * (b[2] - b[1] + 1) < b[0] * (a[2] - a[1] + 1)) return a;
    return b;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #if !ONLINE_JUDGE && !EVAL
        ifstream cin("input.txt");
        ofstream cout("output.txt");
    #endif
    cin >> n >> s; s = '#' + s; rs = {1, 0, 0};
    for (i = 1; i <= 26; i++) {
        for (j = 0; j <= 25; j++) f[j] = 0;
        l = 1; r = 0; k = 0;
        while (l <= n) {
            if (r == n || k > i) {
                m = (ll)s[l] - 'a';
                f[m]--; l++;
                if (f[m] == 0) k--;
            } else {
                r++; m = (ll)s[r] - 'a';
                f[m]++;
                if (f[m] == 1) k++;
            }
            if (k <= i) rs = mxx(rs, {i, l, r});
        }
    }
    cout << rs[1] _ rs[2] << nl;
    return 0;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |