Problem G
Suffix Sorting
Input
The input consists of less than $10$ test cases. Each test case begins with a line containing a non-empty string s, of length at most $100\, 000$. Then follows a line containing an integer $n$ followed by $n$ integers $q_1, \ldots , q_ n$, where $0 \le q_{i} < \operatorname {length}(s)$, each indicating a query.
Output
For each test case, output a line containing $n$ integers $p_{1}, \ldots , p_{n}$, where $p_{i}$ is the starting position of the $q_{i}$’th smallest suffix of s.
Sample Input 1 | Sample Output 1 |
---|---|
popup 5 0 1 2 3 4 Popup 5 0 1 2 3 4 Suffixes are jolly fun, eh old chap? 7 35 3 18 33 26 6 2 |
1 4 0 2 3 0 1 4 2 3 17 18 19 20 21 22 23 |