# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
206480 | rzbt | Nivelle (COCI20_nivelle) | C++14 | 50 ms | 508 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>
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define MAXN 100005
using namespace std;
int n;
char s[MAXN];
set<int> gde;
int niz[29];
int l=1,r=1,razl=1;
int main()
{
scanf("%d", &n);
scanf("%s",s);
gde.insert(0);
for(int i=1;i<=n;i++){
int slovo=s[i-1]-'a';
if(niz[slovo])gde.erase(-niz[slovo]);
niz[slovo]=i;
gde.insert(-i);
niz[slovo]=i;
int broj=0;
for(auto x:gde){
//printf(" %d %d %d\n",i,x,broj);
//printf(" %d %d %d %d\n",r-l+1,razl,i+x,broj);
if(broj && (broj*(r-l+1)<(i+x)*razl)){
l=-x+1;
r=i;
razl=broj;
}
broj++;
}
}
printf("%d %d",l,r);
return 0;
}
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... |