Submission #844753

#TimeUsernameProblemLanguageResultExecution timeMemory
844753vjudge1Nivelle (COCI20_nivelle)C++14
0 / 110
11 ms600 KiB
// Aber der schlimmste Fiend, dem du begegnen kannst, wirst du immer dir selber sein
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ff first
#define ss second
#define pb push_back
#define rev reverse
#define all(x) x.begin(),x.end()
#define acc accumulate
#define sz size()
#define MOD 1000000007
#define rall(x) x.rbegin(),x.rend()
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const int N = 1e6 + 5;
inline void solve(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    double mn = n + 1, l, r;
    rep(i, 1, 26){
        int cnt[26];
        fill(cnt, cnt+26, 0);
        int cur = 0;
        int ll = 0;
        rep(j, 0, n){
            if(!cnt[s[j] - 'a']){
                cur++;
                cnt[s[j] - 'a']++;
            }
            while(cur > i){
                cnt[s[ll] - 'a']--;
                if(!cnt[s[ll] - 'a']) cur--;
                ll++;
            }
            if(cur == i){
                double ans = (double)i / (j - ll + 1);
                if(mn > ans) mn = ans, l = ll, r = j; 
            }
        }
    }
    cout << l+1 << " " << r+1 << endl;
}
int main(){
    fast_io
    int t;
    t = 1;
    while(t--) solve();
}

Compilation message (stderr)

nivelle.cpp: In function 'void solve()':
nivelle.cpp:46:29: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized]
   46 |     cout << l+1 << " " << r+1 << endl;
      |                             ^
nivelle.cpp:46:15: warning: 'l' may be used uninitialized in this function [-Wmaybe-uninitialized]
   46 |     cout << l+1 << " " << r+1 << endl;
      |               ^
#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...