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 lg(a) (31 - __builtin_clz((a)))
#define endl ("\n")
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define vi vector<int>
#define all(aa) aa.begin(), aa.end()
#define forn(i, n) for(int i=0;i<n;i++)
#define trav(e, x) for(auto& e:x)
#define until(n, v) (int) (lower_bound(v.begin(), v.end(), n)-v.begin()) //# of elements < n
#define after(n, v) (int) (v.end()-upper_bound(v.begin(), v.end(), n)) //# of elements > n
#define sameas(n, v) (int) (upper_bound(v.begin(), v.end(), n) - lower_bound(v.begin(), v.end(), n)) //# of elements ==n
typedef long long ll;
using namespace std;
/*
*/
void solve(){
int n; cin>>n;
string s; cin>>s;
multiset<char> let;
set<char> cnt;
double average=1;
int L=0, R=n-1;
for(int i=0;i<n;i++){
let.clear(); cnt.clear();
for(int j=0;j<=i;j++){
let.insert(s[j]);
cnt.insert(s[j]);
}
if(average > ((double) cnt.size())/(i+1)){
L = 0, R = i;
average = ((double) cnt.size())/(i+1);
}
for(int j=1;j+i<n;j++){
let.erase(s[j-1]);
if(let.count(s[j-1])==0) cnt.erase(s[j-1]);
let.insert(s[j+i]);
cnt.insert(s[i+j]);
if(average > ((double) cnt.size())/(i+1)){
L = j, R = i+j;
average = ((double) cnt.size())/(i+1);
}
}
}
cout<<L+1<<' '<<R+1<<endl;
}
int main(){
solve();
}
# | 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... |