# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
844889 | vjudge1 | Nivelle (COCI20_nivelle) | C++17 | 451 ms | 856 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 <int, int> mp;
int l = 0;
for(int j = 0; j <= n; ) {
if(mp.size() < i) {
if(!mp.count(s[j]))
mp.insert({s[j], 0});
mp[s[j]]++;
j++;
continue;
}
double val = ((double) mp.size()) / (j - l);
if(val < mn) {
mn = val;
L = l;
R = j - 1;
}
if(!mp.count(s[j]))
mp.insert({s[j], 0});
mp[s[j]]++;
j++;
if(mp.size() > i) {
j--;
if(mp[s[l]] == 1)
mp.erase(s[l]);
else
mp[s[l]]--;
if(mp[s[j]] == 1)
mp.erase(s[j]);
else
mp[s[j]]--;
l++;
}
}
}
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... |