This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define OPEN freopen(".in", "r", stdin); \
freopen(".out", "w", stdout);
#else
#define OPEN void(23);
#endif
void solve()
{
int n; cin >> n;
string str; cin >> str; str = '$' + str;
double ans = 2;
pair <int, int> cev;
int l = 1, r = 1;
while(r <= n && l <= n)
{
if(r + 1 <= n && str[r +1] == str[l]) r++;
else
{
l = r +1;
continue;
}
double calc = double(1.0f) / (r - l +1);
if(calc < ans)
{
ans = calc;
cev = {l, r};
}
}
bool ok = true;
for(int i = 1; i +1 <= n; i++) ok &= str[i] == str[i +1];
if(!ok)
{
double calc = double(2.0f) / n;
if(calc < ans)
{
ans = calc;
cev = {1, n};
}
}
cerr << ans;
cout << cev.first << " " << cev.second;
return;
}
int32_t main()
{
OPEN;
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int t = 1; //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... |