QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 512 MB مجموع النقاط: 110

#13444. 尼维尔

الإحصائيات

由于过度暴力,原始题目描述已被修改。以下内容适合未成年人阅读。

Bojan 在商店货架上看到了 $N$ 个可爱、毛茸茸且可食用的玩具(耶!),它们从 $1$ 到 $N$ 依次排列。每个玩具都染成了 $26$ 种不同颜色之一。每种颜色用一个英文小写字母表示。Bojan 想吃掉其中的一些玩具(流口水)。

对于任意一组玩具,我们将其多彩度定义为该组玩具中不同颜色的数量除以该组玩具的总数量。Bojan 讨厌多彩。Bojan 非常饿。Bojan 想要吃掉一段连续的玩具子序列。

请帮助 Bojan 找到一段连续的玩具子序列,使得其多彩度尽可能小。

输入格式

第一行包含一个整数 $N$ ($1 \le N \le 100\,000$),表示玩具数组的长度。

第二行包含一个长度为 $N$ 的字符串 $S$。字符串的第 $i$ 个字符表示货架上第 $i$ 个玩具的颜色。

输出格式

输出两个索引 $L$ 和 $R$ ($1 \le L \le R \le N$),表示所求的连续玩具子序列位于位置 $L, L + 1, \dots, R$。

如果存在多个具有相同最小多彩度的连续子序列,你可以输出其中任意一个的 $L$ 和 $R$。

子任务

子任务 分值 数据范围
1 7 $N \le 100$
2 17 $N \le 2\,000$
3 13 $S$ 仅包含字符 'a' 和 'b'
4 25 $S$ 仅包含字符 'a'、'b'、'c'、'd' 和 'e'
5 48 无附加限制。

样例

输入样例 1

4
honi

输出样例 1

1 4

输入样例 2

7
nivelle

输出样例 2

4 7

输入样例 3

6
ananas

输出样例 3

1 5

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.