CF1028G.Guess the number
NOI/NOI+/CTSC
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
This problem is interactive.
You should guess hidden number x which is between 1 and M=10004205361450474, inclusive.
You could use up to 5 queries.
In each query, you can output an increasing sequence of k≤x integers, each between 1 and M, inclusive, and you will obtain one of the following as an answer:
- either the hidden number belongs to your query sequence, in this case you immediately win;
- or you will be given where the hidden number is located with respect to your query sequence, that is, either it is less than all numbers from the sequence, greater than all numbers from the sequence, or you will be given such an i that the hidden number x is between the i-th and the (i+1)-st numbers of your sequence.
See the interaction section for clarity.
Be aware that the interactor is adaptive, i.e. the hidden number can depend on queries the solution makes. However, it is guaranteed that for any solution the interactor works non-distinguishable from the situation when the hidden number is fixed beforehand.
Hacks are allowed only with fixed hidden number. A hack is represented by a single integer between 1 and M. In all pretests the hidden number is fixed as well.
Interaction
You can make up to 5 queries. To make a query print a number k (1≤k≤104) and then an increasing sequence t0<t1<…<tk−1 of k numbers, each between 1 and M, inclusive. If k>x, you lose.
You get one integer as a response.
- If it is −2, it means you made an invalid query or you lost. Exit immediately after receiving −2 and you will see Wrong answer verdict. Otherwise you can get an arbitrary verdict because your solution will continue to read from a closed stream.
- If it is −1, you guessed the number and should terminate too.
- Otherwise you get a number i between 0 and k, inclusive, denoting where the hidden number is, with respect to the printed numbers. If i=0, then x<t0. If i=k, then tk−1<x. Otherwise ti−1<x<ti.
After printing a query do not forget to output end of line and flush the output. Otherwise you will get Idleness limit exceeded. To do this, use:
- fflush(stdout) or cout.flush() in C++;
- System.out.flush() in Java;
- flush(output) in Pascal;
- stdout.flush() in Python;
- see documentation for other languages.
本题为交互式问题。
你需要猜出一个隐藏的整数 x,其取值范围为 1 到 M=10004205361450474(含端点)。
你最多可进行 5 次询问。
每次询问中,你可以输出一个长度为 k≤x 的严格递增整数序列,其中每个数均在 1 到 M(含端点)之间;随后你会收到以下两种响应之一:
- 若隐藏数 x 属于你所提交的序列,则你立即获胜;
- 否则,你会获知隐藏数 x 相对于该序列的位置:即 x 小于序列中所有数、大于序列中所有数,或存在某个下标 i,使得 x 严格位于序列中第 i 个数与第 (i+1) 个数之间。
详见“交互格式”部分以进一步明确规则。
请注意:评测器是自适应的,即隐藏数 x 可能依赖于你的询问内容。但保证对任意合法解法,评测器的行为在统计上不可区分于隐藏数 x 在交互开始前就已固定的情形。
仅允许使用固定的隐藏数进行 hack。一次 hack 由一个位于 1 到 M(含端点)之间的整数表示。所有预测试用例中隐藏数也均为固定值。
交互格式
你最多可进行 5 次询问。每次询问时,请先输出一个整数 k(满足 1≤k≤104),再输出一个长度为 k 的严格递增序列 t0<t1<…<tk−1,其中每个 ti 均在 1 到 M(含端点)之间。若 k>x,你将直接判负。
你将收到一个整数作为响应:
- 若响应为 −2,表示你发出了非法询问或已失败。请在收到 −2 后立即终止程序,此时你将得到 “Wrong answer” 判定;否则因继续从已关闭的输入流读取数据,你可能收到任意其他判定。
- 若响应为 −1,表示你已正确猜中答案,你也应立即终止程序。
- 否则,你将收到一个整数 i(满足 0≤i≤k),表示隐藏数 x 相对于所输出序列的位置:若 i=0,则 x<t0;若 i=k,则 tk−1<x;否则 ti−1<x<ti。
每次输出询问后,请务必输出换行符并刷新输出缓冲区;否则你将收到 “Idleness limit exceeded” 判定。刷新方法如下:
- C++ 中使用
fflush(stdout)或cout.flush(); - Java 中使用
System.out.flush(); - Pascal 中使用
flush(output); - Python 中使用
stdout.flush(); - 其他语言请参考相应文档。
输入输出样例
输入#1
2 0 -1
输出#1
2 2 3 2 20 30 3 5 7 9
说明/提示
In the first example the number 5 is hidden.
在第一个例子中,数字 5 被隐藏了。
输入解题思路,AI测评打分。不知道怎么写?