제출 #844417

#제출 시각아이디문제언어결과실행 시간메모리
844417vjudge1Nivelle (COCI20_nivelle)C++17
24 / 110
1053 ms13660 KiB
#include<bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;
#define pb push_back
#define endl '\n'
#define fi first
#define se second
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define CDIV(a,b) (((a)+(b)-(1))/(b))
const ll inf = 1e17 + 5;
const ll mod = 1e9 + 7;
const ll N = 1e3 + 30;

 
int mod_(int a, int b)
{
    if(a >= 0)return a % b;
    a += (-a/b + 1) * b;
    return a % b;
}


ld eps = 1e-9;

struct p{
    vector<int>pref;
    p()
    {
        pref.assign(26,0);
    }
    p operator-(const p& b)
    {
        p res;
        for(int i = 0; i < 26; ++i)
        {
            res.pref[i] = pref[i] - b.pref[i];
        }
        return res;
    }
};

void solve()
{
    int n;
    string a;
    cin >> n >> a;
    set<char>s;
    vector<p>pref(n);
    pref[0].pref[a[0] - 'a'] = 1;
    for(int i = 1; i < n; ++i)
    {
        pref[i] = pref[i - 1];
        pref[i].pref[a[i] - 'a']++;
    }
    long double ans = 1;
    int ansl = 0, ansr = 0;
    for(int l = 0; l < n; ++l)
    {
        for(int r = l + 1; r < n; ++r)
        {
            p col = pref[r] - (l ? pref[l - 1] : p());
            int cnt = 0;
            for(int i : col.pref)cnt += !!i;
            if((ld)cnt / (r - l + 1) < ans)
            {
                ans = (ld)cnt / (r - l + 1);
                ansl = l;
                ansr = r;
            }
        }
    }
    cout << ansl + 1 << ' ' << ansr + 1 << endl;
}

int main()
{
    fio;
    //int t; cin >> t; while(t--)
    {
        solve();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...