Once again, the twins Reni and Nora managed to fool everybody by switching places. Alex was convinced that he had figured out a strategy for telling them apart. But it turns out he was wrong. Reni and Nora, knowing that he is hopelessly confused, decide to try one of their newly invented games. It consisted of the following:
They choose different pictures of themselves, numbered from to , one or two of which are of Reni and the rest are of Nora. Alex is allowed to ask questions like: "Among the pictures with numbers , is there at least one picture of Reni?". However, to make it more interesting, he can submit a whole group with several such questions and receive the answers to each of them at the same time.
The purpose of the game for Alex is to guess which pictures are of Reni and which are of Nora after some finite number of questions (which in itself would be an achievement for him), but also to minimize both the number of question groups and the total number of questions in them. He needs your help for this. Write a program that finds the required one or two pictures.
Task
Write a program that determines which of the pictures are of Reni and which are of Nora. It must contain the function play that will be compiled with the jury's program.
Implementation details
Your function play must have the following format:
std::vector<int> play (int N, int T);
It will be called only once during one execution of the program with two parameters: the number of pictures and the number of Reni's pictures - . The function should return the indices of the one or two Reni's pictures. Their order does not matter.
For communication with the jury's program you should use the following function:
std::string guess (std::vector< std::vector<int> >& questions);
As a parameter, it receives a group of questions, each containing a set of picture numbers. For example, if Alex wants to ask questions and the first one is about the pictures and , and the second one is about the pictures and , it should be given . It is allowed to have "empty"{} questions that ask nothing (passing as a parameter). They will not count towards the total number of questions used.
The function returns a string composed of and , indicating "no" and "yes" answers to the questions, respectively. Suppose you asked questions in a group. They are numbered with the numbers through in the order in which you submitted them, and correspond to the indices of answers in the string.
You must submit to the system a file twins.cpp that contains the function play. It can also contain other code, functions, and global variables, but it must not contain the main function. Also, you should not read from the standard input or print to the standard output. Your program must include the header file twins.h by instruction to the preprocessor:
#include "twins.h"
Scoring
Each test receives a score that is a fractional number between 0 and 1 inclusive. If a test has a positive score, it is considered a successful test for your solution. Because Nora and Reni encourage even suboptimal games, they use the following scoring system.
Let be the number of calls to the function guess. The evaluation with respect to for all tests is as follows:
Percentage | |
---|---|
100 | 1 |
60 | |
15 | |
10 | |
0 |
Let be the total number of questions you used across all calls to the guess function.
Scoring when
When there are two types of tests. In the first (the first table), and in the second (the second table). The evaluation with respect to in tests when is as follows:
Percentage | |
---|---|
100 | |
10 | |
0 |
Percentage | |
---|---|
100 | |
Scoring when
When in all tests . The evaluation with respect to in tests when is as follows:
Percentage | |
---|---|
If you make an invalid action or do not guess the pictures correctly, you will get score for the test. Otherwise, the score is equal to . For example, on a test with , if and , your score will be .
Input data
The first line will contain two numbers, and .
Output data
The first line will contain a single number, representing the sum of the two numbers.
Constraints and clarifications
# | Score | Constraints |
---|---|---|
1 | 40 | |
2 | 10 | , The indices of the two Reni's pictures are consecutive numbers. |
3 | 50 |
Examples
Participant's function | Jury's program |
---|---|
- | |
Correct! |
Participant's function | Jury's program |
---|---|
- | |
Correct! |
Explanation
Let's look at the first example. After the first two questions which are asked at once, we know that the requested picture is among the first . Similarly, with the last questions, we find out exactly which one it is.
Local Testing
The file Lgrader.cpp is provided for local testing. Put your twins.cpp file together with Lgrader.cpp and twins.h into one folder and compile the three files together. This will give you a program to check the correctness of your function. The program will require two numbers on the first line and . On the next line the program requires the numbers of the pictures that are of Reni. The program will display in detail the steps when performing this test. To change this, you can change the value of the DETAILS constant at the beginning of the code. You can modify this file as you wish.