#P7544. [COCI 2019/2020 #4] Nivelle
[COCI 2019/2020 #4] Nivelle
Description
Bojan saw cute edible plush toys on a store shelf, numbered from to . Each plush toy has one of different colors. Each color is represented by a lowercase English letter .
For any set of toys, we define its “colorfulness” as the number of distinct colors in the set divided by the total number of toys in the set.
Bojan wants to eat these toys, but he does not like having too many colors. Please help Bojan find a contiguous subsequence of toys whose colorfulness is as small as possible.
Input Format
The first line contains a positive integer , the number of toys.
The second line contains a string of length , where the -th character represents the color of the -th toy on the shelf.
Output Format
Output a single line containing two integers , the left and right endpoints of the required contiguous subsequence.
If there are multiple contiguous subsequences with the same (minimal) colorfulness, output any one of them.
4
honi
1 4
7
nivelle
4 7
6
ananas
1 5
Hint
Constraints and Notes
This problem uses bundled subtasks. There are 5 subtasks in total.
- Subtask 1 (7 points): ;
- Subtask 2 (17 points): ;
- Subtask 3 (13 points): the string contains only two characters (you can think of it as there are only two colors in all toys).
- Subtask 4 (25 points): the string contains only five characters (you can think of it as there are only five colors in all toys).
- Subtask 5 (48 points): no special restrictions.
For all testdata, it is guaranteed that and .
[Hints and Help]
Translated from COCI 2019/2020 CONTEST #4 T5 Nivelle.
In COCI, this problem is worth points.
Translated by ChatGPT 5
京公网安备 11011102002149号