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 int long long
#define OYY 1000000005
#define mod 1000000007
#define mid (start+end)/2
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
map<char,int> mp;
int vis[100005];
vector <pair<int,int>> v(27);
int32_t main(){
faster
int n,maxi=0;cin>>n;
string s;cin>>s;
for(int i=0;i<n;i++){
mp[s[i]]++;
maxi=max(maxi,mp[s[i]]);
int deg=s[i]-'a';
if(v[deg].first==0)v[deg].first=i+1;
else v[deg].first=min(v[deg].first,i+1);
v[deg].second=max(v[deg].second,i+1);
}
int l=OYY,r=0;
map<char,int> ::iterator it=mp.begin();
while(it!=mp.end()){
if(it->second==maxi){
int deg=it->first-'a';
l=min(l,v[deg].first);
r=max(r,v[deg].second);
}
it++;
}
cout<<l<<" "<<r<<'\n';
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... |