#P12505. 「CEOI2025」等于 mex
「CEOI2025」等于 mex
Description
It is well known among Romanian noblemen that the beauty of an integer array is the number of positive integers for which you can split the array into disjoint subarrays (sequences of consecutive elements) such that each element is contained in exactly one subarray and all the subarrays have the same minimum excluded element. The minimum excluded element of an integer array is the smallest strictly positive integer (greater than ) that does not appear in the array.
You are given an integer array and queries of the form , where for all .
For each query, you have to find the beauty of the array .
Implementation Details
You should implement the following procedure:
std::vector<int> solve(
int n, std::vector<int>& v,
int q, std::vector<std::pair<int, int>>& queries);
- : the size of the integer array
- : array of length , the initial array
- : the number of queries
- : array of length describing the queries
- This procedure should return a vector of integers containing the answer for each query.
- This procedure is called exactly once for each test case.
Constraints
- for all
- for all
Subtasks
- (4 points) ,
- (6 points)
- (17 points)
- (10 points) and for all
- (30 points)
- (33 points) No additional constraints.
Example 1
Consider the following call:
solve(10, {1, 1, 2, 2, 3, 3, 1, 2, 3, 4}, 2, {{0, 5}, {0, 8}})
In this sample and there are queries for which:
- and
- and
For the first query, we can split the interval in only one subarray, which is from position to position .
In the second query, could be either or . A possibility of splitting into subarray is by choosing the subarray from position to position . A possibility of splitting into subarrays is by choosing the subarray from position to position and from position to position .
The answer for the first query is and for the second query, it is , so the call to solve
will return {1, 2}
.
Sample grader
The sample grader reads the input in the following format:
- line :
- line :
- line : for all
and outputs lines, the result of the call to function solve
with the corresponding parameters.