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
int const N=2e5+5;
int const mod=1e9+7;
int nxt[N][30];
int main(){
int n;
cin>>n;
string s;
cin>>s;
for(int i=0;i<30;i++)
nxt[n][i]=n;
for(int i=n-1;i>=0;i--){
for(int j=0;j<30;j++)
nxt[i][j]=nxt[i+1][j];
nxt[i][s[i]-'a']=i;
}
int l=0,r=0;
int len=1,d=1;
for(int i=0;i<n;i++){
sort(nxt[i],nxt[i]+26);
for(int c=0;c<=26;c++){
int ln=nxt[i][c]-i;
if(c*len<d*ln){
// cout<<i<<' '<<c<<endl;
l=i;
r=nxt[i][c]-1;
d=c;
len=ln;
}
}
}
cout<<l+1<<' '<<r+1<<endl;
return 0;
}
# | 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... |