CF1008E.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 aa and bb from 11 to nn and Vitya tries to guess them. Each round he tells Vasya two numbers xx and yy from 11 to nn. If both x=ax=a and y=by=b then Vitya wins. Else Vasya must say one of the three phrases:

  1. xx is less than aa;
  2. yy is less than bb;
  3. xx is greater than aa or yy is greater than bb.

Vasya can't lie, but if multiple phrases are true, he may choose any of them. For example, if Vasya thought of numbers 22 and 44, then he answers with the phrase 33 to a query (3,4)(3, 4), and he can answer with the phrase 11 or phrase 33 to a query (1,5)(1, 5).

Help Vitya win in no more than 600600 rounds.

这是一个交互式问题。

瓦夏和维佳在玩一个游戏。瓦夏心中想好了两个整数 aa 和 bb,均在 11 到 nn 之间;维佳尝试猜出这两个数。每轮中,维佳向瓦夏报出两个数 xx 和 yy(均在 11 到 nn 之间)。若 x=ax = a 且 y=by = b,则维佳获胜;否则,瓦夏必须从以下三种说法中选择一种回答:

  1. xx 小于 aa;
  2. yy 小于 bb;
  3. xx 大于 aa 或 yy 大于 bb。

瓦夏不能说谎,但如果多个说法同时为真,他可以任选其一作答。例如,若瓦夏想的数是 22 和 44,那么对于查询 (3,4)(3, 4),他必须回答第 3 种说法;而对于查询 (1,5)(1, 5),他既可以回答第 1 种说法,也可以回答第 3 种说法。

请帮助维佳在不超过 600600 轮内获胜。

输入格式

The first line contains a single integer nn (1≤n≤10181 \leq n \leq 10^{18}) — the upper limit of the numbers.

第一行包含一个整数 nn(1≤n≤10181 \leq n \leq 10^{18})—— 数字的上限。

输入输出样例

  • 输入#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 22 and 44. The interactor was given two instructions.

For the query (4,3)(4, 3), it can return 22 or 33. Out of the two instructions the second one is chosen, so the interactor returns a223=3a^{23}_2=3.

For the query (3,4)(3, 4), it can return only 33.

For the query (3,3)(3, 3), it can return 22 or 33. 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=2a^{23}_1=2.

For the query (1,5)(1, 5), it can return 11 or 33. Out of the two instructions the first one is chosen, so the interactor returns a113=1a^{13}_1=1.

In the fifth query (2,4)(2, 4), the numbers are guessed correctly, the player wins.

我们来分析样例测试。玩家选择的数字是 22 和 44。交互器收到了两条指令。

对于查询 (4,3)(4, 3),交互器可返回 22 或 33。在两条指令中,选择了第二条,因此交互器返回 a223=3a^{23}_2=3。

对于查询 (3,4)(3, 4),交互器只能返回 33。

对于查询 (3,3)(3, 3),交互器可返回 22 或 33。在两条指令中,选择了第一条(因为在返回值相等的情况下,优先选择较小的数),因此交互器返回 a123=2a^{23}_1=2。

对于查询 (1,5)(1, 5),交互器可返回 11 或 33。在两条指令中,选择了第一条,因此交互器返回 a113=1a^{13}_1=1。

在第五次查询 (2,4)(2, 4) 中,玩家正确猜出了这两个数字,获胜。

输入解题思路,AI测评打分。不知道怎么写?

首页