QOJ.ac

QOJ

时间限制: 6 s 内存限制: 512 MB 总分: 100 可 Hack ✓

#6624. 字符串问题

统计

JB 讨厌解决字符串问题。因此,当他的朋友 Potato 给他一个字符串问题时,他会立即把它交给你,然后继续玩世界上最棒的游戏——《原神》。

给定一个字符串,对于每一个非空前缀,你需要找到字典序最大的子串,并指出该最大子串在当前前缀中出现的最左侧位置。

输入格式

仅一行,包含一个字符串 $S$ ($1 \le |S| \le 10^6$),由小写拉丁字母 $a$ 到 $z$ 组成。

输出格式

输出 $|S|$ 行,第 $i$ 行包含两个整数 $l_i$ 和 $r_i$,表示长度为 $i$ 的前缀中字典序最大的子串的最左侧出现位置(起始下标为 $1$)。

样例

样例输入 1

potato

样例输出 1

1 1
1 2
3 3
3 4
3 5
5 6

样例输入 2

pbpbppb

样例输出 2

1 1
1 2
1 3
1 4
1 5
5 6
5 7

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#890EditorialOpenNew Editorial for Problem #6624qqqaaazzz2026-01-29 20:08:35View

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.