# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
844875 | vjudge1 | Nivelle (COCI20_nivelle) | C++17 | 61 ms | 640 KiB |
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 fast cin.tie(0)->sync_with_stdio(0);
#define int long long
#define inf ((int)1e18)
#define N 200005
using namespace std;
int32_t main(){
fast
int n;
cin>>n;
string s;
cin>>s;
double mn = 100, L = 0, R = 0;
for(int i = 1; i <= min(n, 26ll); i++) {
map <char, int> mp;
mp.insert({s[0], 1});
int l = 0;
for(int j = 1; j < n; j++) {
if(mp.size() < i) {
if(!mp.count(s[j]))
mp.insert({s[j], 0});
mp[s[j]]++;
if((double)mp.size() / (j - l + 1) < mn) {
mn = (double)mp.size() / (j - l + 1);
L = l, R = j;
}
continue;
}
//mp.size() == i
if(!mp.count(s[j])) {
if(mp[s[l]] == 1)
mp.erase(s[l]);
else
mp[s[l]]--;
l++;
j--;
continue;
}
if((double)mp.size() / (j - l + 1) < mn) {
mn = (double)mp.size() / (j - l + 1);
L = l, R = j;
}
}
}
cout<<++L<<" "<<++R<<"\n";
}
Compilation message (stderr)
# | 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... |