twins

Time limit: 0.5s Memory limit: 256MB Input: Output:

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 NN different pictures of themselves, numbered from 11 to NN, 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 p1, p2, ... pK (1KN)p_1,\ p_2,\ ...\ p_K\ (1 \leq K \leq N), 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 NN and the number of Reni's pictures - T (T{1,2})T\ ( T\in \{1,2\} ). 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 22 questions and the first one is about the pictures 11 and 22, and the second one is about the pictures 22 and 33, it should be given { {1,2}, {2,3} }\{\ \{1,2\},\ \{2,3\}\ \}. It is allowed to have "empty"{} questions that ask nothing (passing {{ }, {2,3} }\{ \{\ \},\ \{2,3\}\ \} as a parameter). They will not count towards the total number of questions used.

The function returns a string composed of 00 and 11, indicating "no" and "yes" answers to the questions, respectively. Suppose you asked MM questions in a group. They are numbered with the numbers 00 through M1M-1 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 CC be the number of calls to the function guess. The evaluation with respect to CC for all tests is as follows:

Percentage PCP_C CC
100 1
60 3\leq 3
15 17\leq 17
10 34\leq 34
0 >34> 34

Let LL be the total number of questions you used across all calls to the guess function.

Scoring when T=1T=1

When T=1T=1 there are two types of tests. In the first N[15,30]N\in [15,30] (the first table), and in the second N=50 000N=50\ 000 (the second table). The evaluation with respect to LL in tests when T=1T=1 is as follows:

Percentage PLP_L LL
100 10\leq 10
10 30\leq 30
0 >30> 30
Percentage PLP_L LL
100 16\leq 16
100L165016×20100-\frac{L-16}{50-16}\times 20 50\leq 50
80(L50200050)0.4×3580-(\frac{L-50}{2000-50})^{0.4}\times 35 2 000\leq 2 \ 000
45(L2000500002000)0.3×4045-(\frac{L-2000}{50000-2000})^{0.3}\times 40 50 000\leq 50 \ 000
00 >50 000> 50 \ 000

Scoring when T=2T=2

When T=2T=2 in all tests N=50 000N=50\ 000. The evaluation with respect to LL in tests when T=2T=2 is as follows:

Percentage PLP_L LL
100100 152\leq 152
100(L152260152)0.5×15100-(\frac{L-152}{260-152})^{0.5}\times 15 260\leq 260
85L260290260×1085-\frac{L-260}{290-260}\times 10 290\leq 290
75(L290550290)0.3×1075-(\frac{L-290}{550-290})^{0.3}\times 10 550 \leq 550
65(L5502000550)0.6×2065-(\frac{L-550}{2000-550})^{0.6}\times 20 2000\leq 2000
45(L2000500002000)0.3×4045-(\frac{L-2000}{50000-2000})^{0.3}\times 40 50 000 \leq 50\ 000
00 >50 000> 50 \ 000

If you make an invalid action or do not guess the pictures correctly, you will get score 00 for the test. Otherwise, the score is equal to PC×PLP_C \times P_L. For example, on a test with T=2T=2, if L=2000L = 2000 and P=3P = 3, your score will be 45%×60%=0.2745\% \times 60\% = 0.27.

Input data

The first line will contain two numbers, aa and bb.

Output data

The first line will contain a single number, representing the sum of the two numbers.

Constraints and clarifications

  • 15N50 00015 \leq N \leq 50\ 000
  • 1T21 \leq T \leq 2
# Score Constraints
1 40 T=1T = 1
2 10 T=2T = 2, The indices of the two Reni's pictures are consecutive numbers.
3 50 T=2T = 2

Examples

Participant's function Jury's program
- play(6,1)play(6, 1)
guess({{1,2,3},{4,5,6}})guess(\{ \{1,2,3\}, \{4,5,6\} \}) 1010
guess({{1},{2},{3}})guess(\{ \{1\}, \{2\}, \{3\} \}) 010010
return{2}return \{2\} Correct!
Participant's function Jury's program
- play(6,2)play(6, 2)
guess({{1,2},{3,4},{5,6}})guess(\{ \{1,2\}, \{3,4\}, \{5,6\} \}) 011011
guess({{3},{5}})guess(\{ \{3\}, \{5\} \}) 0101
return{5,4}return \{5,4\} 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 33. Similarly, with the last 33 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  N- \ N and TT. 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.

Log in or sign up to be able to send submissions!