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("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX
#include<bits/stdc++.h>
using namespace std;
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
const int mod=1e9+7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int mul(int a,int b)
{
return ((a)*1ll*(b))%mod;
}
void add(int &a,int b)
{
a+=b;
if(a>=mod)a-=mod;
}
int sub(int a,int b){
a-=b;
if(a<0){
a+=mod;
}
return a;
}
int powz(int a,int b)
{
int res=1;
while(b)
{
if(b&1){
res=mul(res,a);
}
b/=2;
a=mul(a,a);
}
return res;
}
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
input>>x.F>>x.S;
return input;
}
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
for(auto& i:x)
input>>i;
return input;
}
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
for(auto& i:x)
output<<i<<' ';
return output;
}
const int N=1000002;
void solve(){
int n;
cin>>n;
string s;
cin>>s;
vector<int>lst(26,-1);
double ans=1e9;
int l=0,r=0;
for(int i=0;i<n;i++){
lst[s[i]-'a']=i;
vector<int>ls;
for(int j=0;j<26;j++){
if(lst[j]!=-1){
ls.pb(lst[j]);
}
}
sort(all(ls));
for(int j=ls.size()-1;j>=0;j--){
if(j>0){
double val=(double)((double)(ls.size()-j)/(double)(i-ls[j-1]));
if(ans>val){
ans=val;
r=i+1;
l=ls[j-1]+2;
}
}
else{
if(ans>(double)((ls.size()-j)/(double)(i+1))){
ans=(double)(ls.size()-j)/(double)(i+1);
l=1;
r=i+1;
}
}
}
}
cout<<l<<' '<<r;
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int tc=1;
//~cin>>tc;
for(int _=0;_<tc;_++){
//~ cout<<"Case #"<<_+1<<": ";
solve();
if(_!=tc-1)
cout<<"\n";
}
}
Compilation message (stderr)
nivelle.cpp:2:0: warning: ignoring #pragma GCC option [-Wunknown-pragmas]
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
# | 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... |