# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
844432 | vjudge1 | Nivelle (COCI20_nivelle) | C++17 | 18 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>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define s second
#define f first
typedef long long ll;
const ll MOD = 998244353;
const ll LOGN = 20;
const ll MAXN = 1e6 + 5;
int cnt[26];
int main() {
fast
int N;
string s;
cin >> N >> s;
s = "#" + s;
double rate = 10.0;
int ansL = -1, ansR = -1;
for (int i = 1; i <= 26; i++) {
memset(cnt, 0, sizeof(cnt));
set<int> now;
int L = 1;
for (int R = 1; R <= N; R++) {
now.insert(s[R] - 'a');
cnt[s[R]]++;
while (now.size() > i) {
cnt[s[L]]--;
if (cnt[s[L]] == 0)
now.erase(s[L] - 'a');
L++;
}
int all = R - L + 1;
int q = i;
double new_rate = ((double)q) / ((double)all);
if (new_rate < rate) {
rate = new_rate;
ansL = L;
ansR = R;
}
}
}
cout << ansL << " " << ansR << "\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... |