Suffix array#2894

Suffix array

1 segundo
128 megabytes
Muy fácil (≈850)

Given a string, construct its suffix array. The suffix array is an array of all suffixes of the string sorted in lexicographical order. Each suffix is represented by its starting position (an integer).

A string is considered lexicographically smaller than string if there exists some such that s_i < t_i and s_j = t_j for all j < i. If no such exists and string is shorter than , then is also considered smaller.

Here, s_i refers to the code of the -th character of string .

Entrada

One line — an English text. The length of the text does not exceed 10^5. The codes of all characters in the text are in the range from to .

Salida

Output integers — the suffix array of the given string.

Ejemplos

Ejemplo 1

Loading
Loading