(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #198251

#TimeUsernameProblemLanguageResultExecution timeMemory
198251alradNivelle (COCI20_nivelle)C++17
110 / 110
44 ms632 KiB
#include <bits/stdc++.h> using namespace std; typedef long double ld; int main() { ios_base :: sync_with_stdio(0); cin.tie(0) , cout.tie(0); int n; cin >> n; vector<char> s(n); for (int i = 0; i < n; i++) { cin >> s[i]; } long double ans = 2.0; int L = 0 , R = 0; for (int cnt = 1; cnt <= 26; cnt++) { vector<int> tot(26 , 0); int r = 0 , x = 0; for (int i = 0; i < n; i++) { while (r < n && x <= cnt) { if (!tot[int(s[r] - 'a')]) { if (x + 1 > cnt) { break; } x++; } tot[int(s[r] - 'a')]++; r++; } if (ld(cnt) / ld(r - i) < ans) { ans = ld(cnt) / ld(r - i); L = i; R = r - 1; } if (tot[int(s[i] - 'a')] == 1) { x--; } tot[int(s[i] - 'a')]--; } } cout << L + 1 << " " << R + 1 << '\n'; return 0; }
#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...