# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1017208 | vjudge1 | Nivelle (COCI20_nivelle) | C++17 | 183 ms | 756 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;
int main(){
int n;
string s;
cin >> n >> s;
vector<pair<long double, pair<int, int>>> vec;
for (int d = 1; d <= 26; d ++){
// cout << "-- " << d << endl;
int j = 0;
int len = 0;
map<char, int> cnt;
pair<int, int> best = {-1, -1};
for (int i = 0; i < n; i ++){
cnt[s[i]]++;
if (cnt.size() == d){
if (len < (i - j + 1)){
len = i - j + 1;
best = {j, i};
}
}
while (cnt.size() > d){
cnt[s[j]]--;
if (cnt[s[j]] == 0)
cnt.erase(s[j]);
j++;
}
}
if (len == 0) continue;
int g = gcd(d, len);
double num = d / g;
double denum = len / g;
// cout << num << " / " << denum << " " << best.first << " -- " << best.second << endl;
vec.push_back({num / denum, best});
}
sort(vec.begin(), vec.end());
cout << vec[0].second.first + 1 << " " << vec[0].second.second + 1 << endl;
}
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... |