This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 i = 1; i <= 26; i++) {
vector<int> m(26);
int cnt = 0, l = 0;
for (int r = 0; r < n; r++) {
if (m[s[r] - 'a'] == 0) cnt++;
m[s[r] - 'a']++;
while (cnt > i) {
m[s[l] - 'a']--;
if (m[s[l] - 'a'] == 0) cnt--;
l++;
}
if ((double) i / (r - l + 1) < d) {
d = (double) i / (r - l + 1);
ans = make_pair(l, r);
}
}
}
cout << ans.first + 1 << " " << ans.second + 1 << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |