제출 #686473

#제출 시각아이디문제언어결과실행 시간메모리
686473Vladth11Nivelle (COCI20_nivelle)C++17
110 / 110
36 ms720 KiB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "

using namespace std;
typedef long long ll;
typedef pair <int, int> pii;

const ll NMAX = 300002;
const ll VMAX = 41;
const ll INF = (1LL << 59);
const ll MOD = 998244353;
const ll BLOCK = 318;
const ll base = 31;
const ll nrbits = 21;

int f[26];

int main() {
#ifdef HOME
    ifstream cin(".in");
    ofstream cout(".out");
#endif // HOME
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, i;
    double minim = 2e9;
    cin >> n;
    string s;
    cin >> s;
    pii sol = {-1, -1};
    for(int nrc = 1; nrc <= 26; nrc++){
        int j = 0;
        int curent = 0, maxim = 0;
        pii unde = {-1, -1};
        for(int j = 0; j < 26; j++) f[j] = 0;
        for(i = 0; i < s.size(); i++){
            f[s[i] - 'a']++;
            if(f[s[i] - 'a'] == 1)
                curent++;
            while(curent > nrc){
                f[s[j] - 'a']--;
                if(f[s[j] - 'a'] == 0)
                    curent--;
                j++;
            }
            maxim = max(maxim, i - j + 1);
            if(maxim == i - j + 1){
                unde = {j + 1, i + 1};
            }
        }
        minim = min(minim, (double)nrc / (double)maxim);
        if(minim == (double)nrc / (double)maxim){
            sol = unde;
        }
    }
    cout << sol.first << " " << sol.second;
    return 0;
}

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

nivelle.cpp: In function 'int main()':
nivelle.cpp:40:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for(i = 0; i < s.size(); i++){
      |                    ~~^~~~~~~~~~
#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...