If you visit the prehistoric stone circle of Stonehenge at dawn on the longest day of the year, the druids will challenge you to participate in the ancient and sacred pebble game. First, you will be blindfolded, so that you are unable to see anything.
Then, the chief druid will tell you that she has $$$N$$$ piles of stones in a line, where $$$N$$$ is a power of two ($$$N = 2^k$$$ for some integer $$$k$$$).
Piles are indexed from $$$0$$$ to $$$N-1$$$. Each pile has a height $$$H_i$$$, which is a positive integer, and the piles are ordered from smallest to tallest ($$$H_0 \le H_1 \le \ldots \le H_{N-1}$$$). The chief druid tells you the value of $$$N$$$, but not the initial heights.
You can then choose actions of one of the following types:
Your goal is to reach a configuration where all piles have the same height. You take at most $$$Q_\mathrm{add}$$$ actions of the first type, and at most $$$Q_\mathrm{compare}$$$ actions of the second type (see section Scoring).
Implementation Details
You will have to submit a single .cpp source file.
Among this task's attachments you will find a template equal.cpp with a sample implementation.
You have to implement the following function:
void make_all_equal(int N, int Q_add, int Q_compare);
You can call the following functions:
void add(vector<int> S, long long X);
bool compare(int i, int j);
The task's directory contains a simplified version of the jury grader, which you can use to test your solution locally. The simplified grader reads the input data from stdin, calls the functions that you must implement, and finally writes the output to stdout.
The input is made up of two lines, containing:
Constraints
If your program is judged as Accepted, the sample grader prints Accepted: add=U, compare=V where $$$U$$$ and $$$V$$$ are the number of times you called add and compare.
If your program is judged as Wrong Answer, the sample grader prints Wrong Answer: MSG, where MSG is one of:
| Message | Meaning |
| too many calls to add | You called add more than $$$Q_\mathrm{add}$$$ times. |
| X out of range | The integer $$$X$$$ given to add is not between $$$0$$$ and $$$10^{12}$$$ inclusive. |
| index in S out of range | An element of the vector $$$S$$$ given to add is not between $$$0$$$ and $$$N-1$$$ inclusive. |
| indices in S not distinct | There are two equal elements in the vector $$$S$$$ given to add. |
| too many calls to compare | You called compare more than $$$Q_\mathrm{compare}$$$ times. |
| i out of range | The integer $$$i$$$ given to compare is not between $$$0$$$ and $$$N-1$$$ inclusive. |
| j out of range | The integer $$$j$$$ given to compare is not between $$$0$$$ and $$$N-1$$$ inclusive. |
| heights are not equal | After calling make_all_equal, there are two piles with different heights. |
Example interaction.
| Name |
|---|


