QOJ.ac

QOJ

Límite de tiempo: 3 s Límite de memoria: 128 MB Puntuación total: 100

#956. Suffix Sorting

Estadísticas

This is a template problem.

Read a string of length $n$ consisting of uppercase letters, lowercase letters, or digits. Sort all non-empty suffixes of this string in lexicographical order, and output the starting positions of these suffixes in the original string in order. The positions are numbered from $1$ to $n$.

Input

A single line containing a string of length $n$ consisting only of uppercase letters, lowercase letters, or digits.

Output

A single line containing $n$ integers, where the $i$-th integer is $\text{SA}[i]$.

Subtasks

Subtask 1 (25 points), $1 \leq n \leq 10^3$

Subtask 2 (25 points), $1 \leq n \leq 10^4$

Subtask 3 (25 points), $1 \leq n \leq 10^5$

Subtask 4 (25 points), $1 \leq n \leq 10^6$

Examples

Input 1

ababa

Output 1

5 3 1 4 2

Input 2

0103210002010200210200101020202222010111

Output 2

7 21 8 15 22 35 11 24 1 37 19 13 9 26 28 16 30 3 40 6 23 36 18 12 25 2 39 38 20 14 34 10 27 29 5 17 33 32 31 4

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.