# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
686473 | Vladth11 | Nivelle (COCI20_nivelle) | C++17 | 36 ms | 720 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>
#pragma GCC optimize("Ofast")
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
const ll NMAX = 300002;
const ll VMAX = 41;
const ll INF = (1LL << 59);
const ll MOD = 998244353;
const ll BLOCK = 318;
const ll base = 31;
const ll nrbits = 21;
int f[26];
int main() {
#ifdef HOME
ifstream cin(".in");
ofstream cout(".out");
#endif // HOME
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, i;
double minim = 2e9;
cin >> n;
string s;
cin >> s;
pii sol = {-1, -1};
for(int nrc = 1; nrc <= 26; nrc++){
int j = 0;
int curent = 0, maxim = 0;
pii unde = {-1, -1};
for(int j = 0; j < 26; j++) f[j] = 0;
for(i = 0; i < s.size(); i++){
f[s[i] - 'a']++;
if(f[s[i] - 'a'] == 1)
curent++;
while(curent > nrc){
f[s[j] - 'a']--;
if(f[s[j] - 'a'] == 0)
curent--;
j++;
}
maxim = max(maxim, i - j + 1);
if(maxim == i - j + 1){
unde = {j + 1, i + 1};
}
}
minim = min(minim, (double)nrc / (double)maxim);
if(minim == (double)nrc / (double)maxim){
sol = unde;
}
}
cout << sol.first << " " << sol.second;
return 0;
}
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... |