Problem list
Log in
#coci00545 · COCI 2019/2020 Contest 4

Nivelle

Gold I 1.0 s 512 MB

Original task description has been altered due $to$ excessive violence. The following program $is$ suitable for minors. Bojan sees $N$ cute little fluffy edible toys (yaay!) on a store shelf, ordered from 1 to $N$. Each fluffy toy is colored in one of 26 different colors. Each color is denoted by a lowercase letter from the English alphabet. Bojan wants to eat some of these toys (drool). For any set of toys, we can define its colorfulness as the number of different colors of toys in a set, divided by the total number of toys in a set. Bojan hates colorfulness. Bojan is very hungry. Bojan wants to eat a contiguous subsequence of toys. Help Bojan find a contiguous subsequence of toys whose colorfulness is as small as possible.

Input

The first line contains an integer $N$ ($1 \le N \le 100,000$), the length of array of toys from task description. The second line contains a string $S$ of length $N$. The $i$-th character of the string represents the color of $i$-th toy from the shelf.

Output

Output two indices $L$ and $R$ ($1 \le L \le R \le N$), which denote that the sought contiguous subsequence of toys is located at positions $L$, $L + 1$, . . . , $R$. If there exists more than one contiguous subsequence with the same minimal colorfulness, you can output $L$ and $R$ which define any of them.

Constraints

Subtask Score Constraints 1 7 $N \le 100$ 2 17 $N \le 2,000$ 3 13 $S$ contains only letters ’a’ and ’b’ 4 25 $S$ contains only letters ’a’, ’b’, ’c’, ’d’ and ’e’ 5 48 No additional constraints.

Example 1

Input
4
honi
Output
1 4

Example 2

Input
7
nivelle
Output
4 7

Example 3

Input
6
ananas
Output
1 5
Source
COCI 2019/2020 Contest 4
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code