Hazel the botanist visited a special exhibition in the Singapore Botanical Gardens. In this exhibition,
For each plant
For example, suppose
You may assume that Hazel recorded the values
You were asked to compare the heights of
For each pair of different plants
- Plant
is definitely taller than plant : in any configuration of distinct heights consistent with the array we have . - Plant
is definitely shorter than plant : in any configuration of distinct heights consistent with the array we have . - The comparison is inconclusive: neither of the previous two cases applies.
Implementation details
You should implement the following procedure:
void init(int k, std::vector<int> r)
: the number of consecutive plants whose heights determine each individual value . : an array of size , where is the number of plants taller than plant among the next plants in clockwise order.- This procedure is called exactly once, before any calls to
compare_plants
.
int compare_plants(int x, int y)
: labels of the plants to be compared.- This procedure should return:
if plant is definitely taller than plant , if plant is definitely shorter than plant , if the comparison is inconclusive.
- This procedure is called exactly
times.
Examples
Example 1
Consider the following call:
init(3, {0, 1, 1, 2})
Let's say the grader calls compare_plants(0, 2)
. Since
Let's say the grader calls compare_plants(1, 2)
next. For all possible configurations of heights that fit the constraints above, plant
Example 2
Consider the following call:
init(2, {0, 1, 0, 1})
Let's say the grader calls compare_plants(0, 3)
. Since
Let's say the grader calls compare_plants(1, 3)
next. Two configurations of heights
Constraints
for all- There exists one or more configurations of distinct heights of plants consistent with the array
.
Subtasks
- (
points) - (
points) - (
points) - (
points) The correct answer to each call ofcompare_plants
is or . - (
points) - (
points) for each call ofcompare_plants
. - (
points) No additional constraints.
Sample grader
The sample grader reads the input in the following format:
- line
: - line
: - line
: for the -th call tocompare_plants
The sample grader prints your answer in the following format:
- line
: return value of the -th call tocompare_plants
.
Comments