Problem Statement
Radko again wants to know Marti’s sequence . This time, Marti decided to be more helpful and directly say that the sequence consists of bits of and , exactly of which are . This time he will only answer the following question: “Is there a among ?”
Unfortunately, Radko is still too busy and again outsources the task to you. Your program will be tested on 𝑛𝑡𝑒𝑠𝑡𝑠 subtests for each test, and your score will be calculated based on the total number of questions you use to find the respective sequences.
Implementation details
Your function guessOnes
has the following prototype:
std::vector<int> guessOnes(int n, int k);
It will be called times for each test and will receive as arguments the sequence length and the number of ones . The function should return a vector of numbers - the positions of the ones in ascending order.
The jury’s function hasOnes
has the following prototype:
bool hasOnes(int l, int r);
Your program can call it as many times as it wants. It receives two indexes and from to for which you want to ask a question. The function returns whether there is a among . It works with complexity .
Your program must implement the function , but should not contain a function main. Also, it must not read from the standard input or print to the standard output. Your program must also include the header file by an instruction to the preprocessor: #include "ones.h"
As long as it respects these conditions, your program can contain any helper functions, variables, constants, and so on.
Constraints
- Every sequence is uniform random generated.
Subtasks and scoring
The fraction of points you will get on a subtask depends on the total number of questions you ask on a subtest, , and the subtask constant .
If .
Otherwise
Subtasks
# | Points | K | |
---|---|---|---|
1 | 10 | ||
2 | 10 | ||
3 | 10 | ||
4 | 10 | ||
5 | 10 | ||
6 | 10 | ||
7 | 10 | ||
8 | 10 | ||
9 | 10 | ||
10 | 10 |
Local testing
The file Lgrader.cpp
is provided on the system, with which you can test your program locally. To do so, you need to add #include "Lgrader.cpp"
to your code.
The first line of the standard input contains the numbers and .
The next lines contain numbers each – the positions of the ones. If your program successfully finds the correct sequence for each test, it will output the total number of questions you used for all sequences.