#P7907. [Ynoi2005] rmscne
[Ynoi2005] rmscne
Problem Description
Given a sequence of length and queries, for each query interval , find the shortest sub-interval such that every number that appears in also appears in . You only need to output the length of , i.e. .
Input Format
The first line contains one positive integer .
The next line contains positive integers, representing the elements of the sequence.
The next line contains one positive integer .
The next lines each contain two positive integers , representing a query.
Output Format
Output lines, each containing one positive integer representing the answer.
5
1 3 2 3 4
3
2 4
1 3
2 5
2
3
3
Hint
Idea: qwaszx, Solution: qwaszx, Code: qwaszx, Data: qwaszx.
For of the testdata, .
For of the testdata, .
For of the testdata, , .
Translated by ChatGPT 5