This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
* author: limwu
* created:25.08.2022 16:17:13
**/
/* #pragma GCC optimize("Ofast,unroll-loops") */
#include "bits/stdc++.h"
using namespace std;
#ifdef duc_debug
#include "bits/debug.h"
#else
#define debug(...)
#endif
/* #define int long long */
const int maxn = 1e5+5;
int n;
string s;
void solve(){
cin >> n >> s;
int cnt = 26, l = -1, r = -1;
vector<int> a(26, -1), b(27, -1);
for(int i = 0; i < n; ++i){
int ch = s[i] - 'a';
b.erase(find(b.begin(), b.end(), a[ch]));
a[ch] = i;
b.insert(b.begin(), i);
for(int j = 1; j <= 26; ++j){
if(j * (r - l + 1) < cnt * (i - b[j])){
cnt = j;
l = b[j] + 1;
r = i;
}
}
}
cout << l + 1 << " " << r + 1;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int test = 1;
/* cin >> test; */
for(int i = 1; i <= test; i++){
/* cout << "Case " << "#" << i << ": "; */
solve();
}
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... |