Micro and String

5

1 votes
Suffix array, Very-Easy, Suffix tree, Suffix array, Data Structures
Problem

Micro is having a string S made of lowercase English alphabets. He wants to find out the index where the suffix having rank i starts, 1i|S|. Help Micro with this.

Input:
The only line of input consists of a string.

Output:
Print N space separated integers, where ith integer denotes the index where the suffix having rank i starts

Constraints:
1|S|10000

Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

Suffixes of string are:
a - 4
ba - 3
aba - 2
aaba - 1
aaaba - 0
Sorted order
a - 4
aaaba - 0
aaba - 1
aba - 2
ba - 3
So , the output is 4 0 1 2 3

Editor Image

?