#P3809. 【模板】后缀排序

    ID: 4530 远端评测题 2000ms 256MiB 尝试: 38 已通过: 9 显示难度提高+/省选− 上传者: 标签>字符串O2优化排序后缀数组 SA

【模板】后缀排序

Background

This is a template problem.

Problem 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