#P4137. Rmq Problem / mex
Rmq Problem / mex
Description
There is an array of length .
There are queries; for each query, find the smallest non-negative integer that does not appear in the interval (mex).
Input Format
The first line contains two positive integers .
The second line contains non-negative integers .
Then follow lines, each containing two positive integers , representing a query.
Output Format
Output lines, one number per line, giving the answer to each query in order.
5 5
2 1 0 2 1
3 3
2 3
2 4
1 2
3 5
1
2
3
0
3
Hint
For of the testdata: .
For of the testdata: , , .
Translated by ChatGPT 5
京公网安备 11011102002149号