제출 #844580

#제출 시각아이디문제언어결과실행 시간메모리
844580vjudge1Nivelle (COCI20_nivelle)C++17
13 / 110
47 ms856 KiB
#include <bits/stdc++.h> using namespace std; #ifdef DEBUG #include "/Users/kutay/CP/templates/debug.h" #else #define debug(...) void(38) #endif #define int long long int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; string s; cin >> s; double d = 1e9; pair<int, int> ans; for (int a = 1; a <= 26; a++) { vector<int> m(26); int l = 0, r = 0; int cnt = 0; while (r < n && cnt <= a) { m[s[r++] - 'a']++; int c = 0; for (int x : m) c += (bool) x; cnt = c; if (c > a) { r--; break; } } r--; if ((double) a / (r - l + 1) - d < -1e-7) { d = (double) a / (r - l + 1); ans = make_pair(l, r); } debug(a, l, r, d); while (r < n - 1) { char c1 = s[++r], c2 = s[l]; while (r < n && c1 == s[r]) { r++; } r--; while (l < n && c2 == s[l]) { l++; } if ((double) a / (r - l + 1) < d) { d = (double) a / (r - l + 1); ans = make_pair(l, r); } } } cout << ans.first + 1 << " " << ans.second + 1 << '\n'; }
#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...