제출 #844757

#제출 시각아이디문제언어결과실행 시간메모리
844757vjudge1Nivelle (COCI20_nivelle)C++14
38 / 110
29 ms772 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'] == 1){
                cur++;
            }
            while(cur > i){
                if(--cnt[s[ll] - 'a'] == 0) cur--;
                ll++;
            }
            if(cur == i){
                double ans = (double)i / (double)(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();
}

컴파일 시 표준 에러 (stderr) 메시지

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