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;
using ll = long long;
using ld = long double;
#define pb push_back
#define endl '\n'
#define fi first
#define se second
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define CDIV(a,b) (((a)+(b)-(1))/(b))
const ll inf = 1e17 + 5;
const ll mod = 1e9 + 7;
const ll N = 1e3 + 30;
int mod_(int a, int b)
{
if(a >= 0)return a % b;
a += (-a/b + 1) * b;
return a % b;
}
void solve()
{
int n;
string s;
cin >> n >> s;
int ans_distin = 26, ansl = -1, ansr = -1;
vector<int> last(26, -1), in_order(26 + 1, -1);
for (int i = 0; i < n; i++) {
int c = s[i] - 'a';
in_order.erase(find(in_order.begin(), in_order.end(), last[c]));
last[c] = i;
in_order.insert(in_order.begin(), i);
for (int j = 1; j <= 26; j++)
if ((ld)ans_distin / (ld)(ansr - ansl + 1) > (ld) j / (ld) (i - in_order[j])) {
ans_distin = j;
ansl = in_order[j] + 1;
ansr = i;
}
}
//cout << (ld)ans_distin / (ansr - ansl + 1) << ' ';
cout << ansl + 1 << " " << ansr + 1 << "\n";
}
int main()
{
fio;
//int t; cin >> t; while(t--)
{
solve();
}
}
# | 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... |