描述
There is a strong data structure called “Suffix Array” which can effectively solve string problems.
Let S=s1s2…sn be a string and let S[i,j] denote the substring of S ranging from i to j. The suffix array A of S is now defined to be an array of integers providing the starting positions of suffixes of S in lexicographical order. This means, an entry A[i] is the starting position of the i-th smallest suffix in S and thus for all 1 < i ≤ n: S[A[i-1], n] < S[A[i], n].
For example: the suffix array of “banana” is [6, 4, 2, 1, 5, 3].
Here comes another problem called “Reverse Suffix Array”.
Given a suffix array, you need to figure out how many lower case strings are there whose suffix array is the same as the given suffix array.
继续阅读“2017ICPC北京网络赛 B | hihocoder 1579 Reverse Suffix Array”