#P3809. 【模板】后缀排序

    ID: 2746 远端评测题 2000ms 256MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>字符串O2优化排序后缀数组,SA

【模板】后缀排序

Description

Read a string of length n n consisting of uppercase and lowercase English letters or digits. Sort all its non-empty suffixes in ascending lexicographic order (compared by ASCII values), then output, in that order, the position in the original string of the first character of each suffix. Positions are numbered from 1 1 to n n .

Input Format

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

Output Format

One line containing n n integers representing the answer.

ababa
5 3 1 4 2

Hint

1n106 1 \le n \le 10^6 .

Translated by ChatGPT 5