luogu#P16387. [IATI 2024] Ones

    ID: 16561 远端评测题 30000ms 256MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>2024交互题Special JudgeIATI(保加利亚/东欧)

[IATI 2024] Ones

Problem Description

Radko again wants to know Marti’s sequence p1,p2,,pnp_1,p_2,\dots,p_n. This time, Marti decided to be more helpful and directly say that the sequence consists of nn bits of 00 and 11, exactly kk of which are 11. This time he will only answer the following question:

  • “Is there a 11 among pl,pl+1,,prp_l,p_{l+1},…,p_r?”

Unfortunately, Radko is still too busy and again outsources the task to you. Your program will be tested on ntestsn_{tests} 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\verb|guessOnes| has the following prototype:

std::vector<int> guessOnes(int n, int k);

It will be called ntestsn_{tests} times for each test and will receive as arguments the sequence length nn and the number of ones kk. The function should return a vector of kk numbers - the positions of the ones in ascending order.

The jury’s function hasOneshasOnes 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 ll and rr from 11 to nn for which you want to ask a question. The function returns whether there is a 11 among pl,pl+1,,prp_l,p_{l+1},…,p_r. It works with complexity O(1)O(1).

Your program must implement the function guessOnes\verb|guessOnes|, but should not contain a function main\verb|main|. Also, it must not read from the standard input or print to the standard output. Your program must also include the header file ones.h\verb|ones.h| by an instruction to the preprocessor: #include "ones.h"\verb|#include "ones.h"|

As long as it respects these conditions, your program can contain any helper functions, variables, constants, and so on.

Local testing

The file Lgrader.cpp\verb|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"\verb|#include "Lgrader.cpp"| to your code.

The first line of the standard input contains the numbers nn, kk and ntestsn_{tests}.

The next ntestsn_{tests} lines contain kk 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.



Hint

Constraints

  • Every sequence is uniform random generated.
  • n=100000n = 100 000
  • ntests=100n_{tests} = 100

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, qparticipantq_{participant}, and the subtask constant qauthorq_{author}.

If qparticipantqauthorq_{participant} \leq q_{author}, score=1score = 1

Otherwise $score = 1 - \sqrt[4]{1 - \frac{q_{author}}{q_{participant}}}$

Subtasks Points kk qauthorq_{author}
11 1010 1010 1448014480
22 2020 2720127201
33 5050 6190861908
44 100100 114144114144
55 200200 208697208697
66 500500 455937455937
77 10001 000 811792811792
88 20002 000 14223961422396
99 50005 000 28796752879675
1010 1000010 000 47237794723779