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;
string s;
int l,r,n,j,ct,ac[150],ok;
double best;
int main()
{
cin>>n>>s;
s='#'+s;
for (int i=1;i<=n;i++){
while (j<=n){
if (j==n) break;
j++;
if (ac[s[j]-'a']==0) ct++;
ac[s[j]-'a']++;
if (l==0) {
best=ct/(double)(j-i+1);
l=i,r=j;
}
//cout<<i<<" "<<j<<" "<<ct/(double)(j-i+1)<<" "<<best<<"\n";
if (best>ct/(double)(j-i+1)){
best=ct/(double)(j-i+1);
l=i,r=j;
}
if (best<ct/(double)(j-i+1)) {
break;
}
}
if (best>ct/(double)(j-i+1)){
best=ct/(double)(j-i+1);
l=i,r=j;
}
ac[s[i]-'a']--;
if (ac[s[i]-'a']==0)--ct;
}
cout<<l<<" "<<r<<"\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... |