# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
199595 | quocnguyen1012 | Nivelle (COCI20_nivelle) | C++14 | 45 ms | 636 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 fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
int N;
string str;
int cnt[26];
signed main(void)
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if (fopen("A.INP", "r")){
freopen("A.INP", "r", stdin);
freopen("A.OUT", "w", stdout);
}
cin >> N >> str;
str = " " + str;
int L = 0, R = 0, mxap = 0;
for (int type = 1; type <= 26; ++type){
int r = 1, ap = 0;
for (int i = 1; i <= N; ++i){
while (r <= N){
if (!cnt[str[r] - 'a']){
if (ap + 1 > type) break;
++ap;
}
++cnt[str[r] - 'a'];
++r;
}
if (mxap == 0 || (mxap * (r - i) > ap * (R - L + 1))){
///cerr << L << ' ' << R << ' ' << mxap << ' ' << i << ' ' << r - 1 << ' ' << ap << '\n';
mxap = ap;
L = i; R = r - 1;
}
--cnt[str[i] - 'a'];
if (cnt[str[i] - 'a'] == 0) --ap;
}
for (int i = 0; i < 26; ++i) cnt[i] = 0;
}
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... |