COCI '19 Contest 4 #5 Nivelle
View as PDFOriginal task description has been altered due to excessive violence. The following program is suitable for minors.
Bojan sees  cute little fluffy edible toys (yaay!) on a store shelf, ordered from 
 to
. Each fluffy toy is colored in one of 
 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  
, the length of array of toys from the task description.
The second line contains a string  of length 
. The 
-th character of the string represents the color of
-th toy from the shelf.
Output
Output two indices  and 
 
, which denote that the sought contiguous subsequence of
toys is located at positions 
.
If there exists more than one contiguous subsequence with the same minimal colorfulness, you can output
 and 
 which define any of them.
Scoring
| Subtask | Score | Constraints | 
|---|---|---|
a and b | 
||
a, b, c, d and e | 
||
| No additional constraints. | 
Sample Input 1
4
honi
Sample Output 1
1 4
Sample Input 2
7
nivelle
Sample Output 2
4 7
Sample Input 3
6
ananas
Sample Output 3
1 5
Comments