# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
844548 | vjudge1 | Nivelle (COCI20_nivelle) | C++17 | 1 ms | 808 KiB |
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;
map<char, int> mp;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, a = 0;
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 = 1; i <= n; i++)
{
if(str[i] != str[i - 1])
{
cnt = 1;
if((long double)1 / (long double)cnt < ans)
{
ans = (long double)1 / (long double)cnt;
left = i, right = i;
}
}
else
{
cnt++;
if((long double)1 / (long double)cnt < ans)
{
ans = (long double)1 / (long double)cnt;
left = i - cnt + 1, right = i;
}
}
}
cout << left << " " << right << '\n';
}
Compilation message (stderr)
# | 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... |