luogu#P3809. 【模板】后缀排序

    ID: 7837 Type: RemoteJudge 2000ms 256MiB Tried: 34 Accepted: 17 Difficulty: 8 Uploaded By: Tags>字符串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