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;
vector<int> m(26);
pair<int, int> ans = make_pair(-1, -1);
double d = 1e9;
for (int i = 0; i < n; i++) {
m = vector<int>(26);
for (int j = i; j < n; j++) {
m[s[j] - 'a'] = 1;
int sum = accumulate(m.begin(), m.end(), 0);
debug(sum, j - i + 1, d);
if ((double) sum / (j - i + 1) < d) {
d = (double) sum / (j - i + 1);
ans = make_pair(i, j);
}
}
}
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... |