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 <stdio.h>
#define N 100000
#define A 26
int main() {
static char cc[N + 1];
static int ii[A];
int n, h, j, cnt, p_, q_, i_, j_;
scanf("%d%s", &n, cc);
cnt = 0, p_ = 1, q_ = 0, i_ = j_ = -1;
for (j = 0; j < n; j++) {
for (h = 0; h < cnt; h++)
if (cc[ii[h]] == cc[j]) {
cnt--;
while (h < cnt)
ii[h] = ii[h + 1], h++;
break;
}
ii[cnt++] = j;
for (h = 0; h < cnt; h++) {
int i = h == 0 ? 0 : ii[h - 1] + 1, p = cnt - h, q = j - i + 1;
if (p_ * q > p * q_)
p_ = p, q_ = q, i_ = i, j_ = j;
}
}
printf("%d %d\n", i_ + 1, j_ + 1);
return 0;
}
Compilation message (stderr)
nivelle.c: In function 'main':
nivelle.c:11:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
11 | scanf("%d%s", &n, cc);
| ^~~~~~~~~~~~~~~~~~~~~
# | 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... |