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;
#define ll long long
const int N = 2e5 + 5, MOD = 1e9 + 7;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
string str;
cin >> n >> str;
str = "#" + str;
int cnt = 1, left = 1, right = n;
long double ans = (long double)2 / (long double)n;
for(int i = 2; i <= n; i++)
{
if(str[i] == str[i - 1])
{
cnt++;
}
else
{
if((long double)1 / (long double)cnt < ans)
{
left = i - cnt;
right = i - 1;
ans = (long double)1 / (long double)cnt;
}
}
}
cout << left << " " << right << '\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... |