#P6152. [集训队作业2018] 后缀树节点数
[集训队作业2018] 后缀树节点数
Description
Given a string of length , there are queries. Each query gives two parameters and asks for the number of nodes in the suffix tree built from the substring .
If you do not know what a suffix tree is, you can also understand it as building a suffix automaton on the reversed string of .
Note that in this problem, the root node of the suffix tree is not included in the answer.
Input Format
In this problem, the string is represented by numbers. Different numbers represent different characters, and the same number represents the same character. The numbers are in the range .
The first line contains two positive integers and , representing the length of the string and the number of queries. The second line contains non-negative integers separated by spaces, representing the string. The next lines each contain two positive integers , representing a query: ask for the number of nodes in the suffix tree of the substring .
Output Format
Output lines. Each line contains one positive integer representing the answer.
7 2
2 1 3 1 3 1 4
1 7
4 5
10
2
Hint
For of the testdata: .
For of the testdata: , , and each number in the string is 。
Translated by ChatGPT 5
京公网安备 11011102002149号