CF1007C.Guess two numbers
NOI/NOI+/CTSC
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
This is an interactive problem.
Vasya and Vitya play a game. Vasya thought of two integers a and b from 1 to n and Vitya tries to guess them. Each round he tells Vasya two numbers x and y from 1 to n. If both x=a and y=b then Vitya wins. Else Vasya must say one of the three phrases:
- x is less than a;
- y is less than b;
- x is greater than a or y is greater than b.
Vasya can't lie, but if multiple phrases are true, he may choose any of them. For example, if Vasya thought of numbers 2 and 4, then he answers with the phrase 3 to a query (3,4), and he can answer with the phrase 1 or phrase 3 to a query (1,5).
Help Vitya win in no more than 600 rounds.
这是一个交互式问题。
瓦夏和维佳在玩一个游戏。瓦夏心中想好了两个整数 a 和 b(均在 1 到 n 之间),维佳尝试猜出它们。每一轮,维佳向瓦夏报出两个数 x 和 y(均在 1 到 n 之间)。若 x=a 且 y=b,则维佳获胜;否则,瓦夏必须从以下三种说法中选择其一作答:
- x 小于 a;
- y 小于 b;
- x 大于 a 或 y 大于 b。
瓦夏不能说谎,但当多个说法同时为真时,他可以任选其一回答。例如,若瓦夏想的数是 2 和 4,那么对于查询 (3,4),他必须回答第 3 种说法;而对于查询 (1,5),他既可回答第 1 种说法,也可回答第 3 种说法。
请帮助维佳在不超过 600 轮内获胜。
输入格式
The first line contains a single integer n (1≤n≤1018) — the upper limit of the numbers.
第一行包含一个整数 n(1≤n≤1018)—— 数字的上限。
输入输出样例
输入#1
5 3 3 2 1 0
输出#1
4 3 3 4 3 3 1 5 2 4
说明/提示
Let's analyze the sample test. The chosen numbers are 2 and 4. The interactor was given two instructions.
For the query (4,3), it can return 2 or 3. Out of the two instructions the second one is chosen, so the interactor returns a223=3.
For the query (3,4), it can return only 3.
For the query (3,3), it can return 2 or 3. Out of the two instructions the first one is chosen (since in case of equal values, the least number is preferred), so the interactor returns a123=2.
For the query (1,5), it can return 1 or 3. Out of the two instructions the first one is chosen, so the interactor returns a113=1.
In the fifth query (2,4), the numbers are guessed correctly, the player wins.
我们来分析样例测试。玩家选择的数字是 2 和 4。交互器收到了两条指令。
对于查询 (4,3),交互器可返回 2 或 3。在两条指令中选择了第二条,因此交互器返回 a223=3。
对于查询 (3,4),交互器只能返回 3。
对于查询 (3,3),交互器可返回 2 或 3。在两条指令中选择了第一条(因为在返回值相等时,优先选择较小的数),因此交互器返回 a123=2。
对于查询 (1,5),交互器可返回 1 或 3。在两条指令中选择了第一条,因此交互器返回 a113=1。
在第五次查询 (2,4) 中,玩家正确猜出了这两个数,获胜。
输入解题思路,AI测评打分。不知道怎么写?