第 1127 场 Codeforces Round(Div. 1,基于 2026 年墨西哥信息学奥林匹克竞赛)
D
灵气对战
Aura Battle
Codeforces
2600
原题
← CE →

灵气对战AI (CI翻译)

This is an interactive problem. Hacks are disabled.

本题为交互题。不支持 Hack。AI (CI翻译)

You're in an aura battle in Pachuca, Mexico. Each battle consists of $10$ rounds. The judges have a hidden integer $x$ ($1 \le x \le 10^4$), which remains fixed throughout the battle.

你正在墨西哥帕丘卡参加一场灵气对战。每场对战由 $10$ 轮组成。裁判掌握一个隐藏整数 $x$($1 \le x \le 10^4$),且在整场对战中保持不变。AI (CI翻译)

In round $i$, you choose two integers $a_i$ and $b_i$ ($-10^9 \le a_i, b_i \le 10^9$). You then lose $$ \min\bigl(|x-a_i|,\ |x-b_i|\bigr) $$ aura and are told this amount before the next round begins. Your choices may depend on the results of all previous rounds. After the battle is over, your total aura loss is calculated as the sum of the aura lost in each of the $10$ rounds.

在第 $i$ 轮中,你需要选择两个整数 $a_i$ 和 $b_i$($-10^9 \le a_i, b_i \le 10^9$)。随后你会损失 $$ \min\bigl(|x-a_i|,\ |x-b_i|\bigr) $$ 点灵气,并在下一轮开始前得知损失的数值。你可以根据之前所有轮次的结果来决定当前选择。对战结束后,你损失的灵气总量为 $10$ 轮中每轮损失的灵气之和。AI (CI翻译)

Let $m$ be the smallest integer such that there exists a strategy guaranteeing a total aura loss of at most $m$, regardless of the hidden value of $x$. Your task is to guarantee a total aura loss not exceeding the limit, which is $10^5$ on the first test (the example) and $m+67$ on all other tests.

令 $m$ 为最小的整数,使得存在一种策略,无论隐藏值 $x$ 是多少,都能保证灵气总损失不超过 $m$。你的任务是保证灵气总损失不超过上限:第一组测试(样例)中上限为 $10^5$,其余测试中上限为 $m+67$。AI (CI翻译)

Input

输入格式

AI (CI翻译)

The first line of input contains a single integer $t$ ($1 \le t \le 10^4$) — the number of battles.

输入的第一行包含一个整数 $t$($1 \le t \le 10^4$)——对战场数。AI (CI翻译)

Interaction

交互

AI (CI翻译)

The $t$ battles are carried out one after another. In every battle, you repeat the following $10$ times:

$t$ 场对战依次进行。在每场对战中,你需要重复以下过程 $10$ 次:AI (CI翻译)

  • print two integers $a_i$ and $b_i$ ($-10^9 \le a_i, b_i \le 10^9$) — the values you play for the $i$-th round;
  • read one integer $p$ — the aura you lost this round, that is, $p = \min(\lvert x - a_i \rvert, \lvert x - b_i \rvert)$, where $x$ is the hidden value of the current battle.
  • 输出两个整数 $a_i$ 和 $b_i$($-10^9 \le a_i, b_i \le 10^9$)——第 $i$ 轮选择的数值;
  • 读入一个整数 $p$——本轮损失的灵气,即 $p = \min(\lvert x - a_i \rvert, \lvert x - b_i \rvert)$,其中 $x$ 是当前这场对战的隐藏值。
AI (CI翻译)

You must play all $10$ rounds of a battle.

每场对战都必须进行完全部 $10$ 轮。AI (CI翻译)

Nothing is printed or read between battles: right after the $10$-th round of a battle, the next battle begins, and after the $10$-th round of the last battle your program must terminate without printing anything else.

两场对战之间不会进行任何读写:一场对战的第 $10$ 轮结束后,下一场对战立即开始;最后一场对战的第 $10$ 轮结束后,程序必须立即终止,不能再输出任何内容。AI (CI翻译)

If you print a value outside $[-10^9, 10^9]$, the interactor stops answering and you will get the verdict Wrong answer. Make sure your program exits immediately in that case, otherwise you may get an arbitrary verdict. You will also get the verdict Wrong answer if the total aura you lose in some battle exceeds the limit, which is $10^5$ on the first test (the example) and $m+67$ on all other tests.

如果输出的数值超出 $[-10^9, 10^9]$,交互器将停止回复,你会得到 Wrong answer 判定。如果发生这种情况,请确保程序立即退出,否则可能会得到任意判定。如果某场对战的灵气总损失超过上限,你也会得到 Wrong answer 判定;第一组测试(样例)的上限为 $10^5$,其余测试的上限为 $m+67$。AI (CI翻译)

After printing a value, do not forget to output the end of line and to flush the output. Otherwise, you will get the verdict Idleness limit exceeded. To do this, use:

输出数值后,别忘了输出换行并刷新输出缓冲区,否则你会得到 Idleness limit exceeded 判定。可以使用:AI (CI翻译)

  • fflush(stdout) or cout.flush() in C++;
  • System.out.flush() in Java;
  • flush(output) in Pascal;
  • stdout.flush() in Python;
  • see the documentation for other languages.
  • C++ 中的 fflush(stdout) 或 cout.flush();
  • Java 中的 System.out.flush();
  • Pascal 中的 flush(output);
  • Python 中的 stdout.flush();
  • 其他语言请参阅相关文档。
AI (CI翻译)

Note

说明

AI (CI翻译)

In the example there is a single battle, and the hidden value $x$ is $40$.

样例中只有一场对战,隐藏值 $x$ 为 $40$。AI (CI翻译)

  • In the first round, $a_1 = 3$ and $b_1 = 53$, so you lose $13 = \min(\lvert 3 - 40 \rvert, \lvert 53 - 40 \rvert)$ aura.
  • In the second round, $a_2 = 36$ and $b_2 = 49$, so you lose $4 = \min(\lvert 36 - 40 \rvert, \lvert 49 - 40 \rvert)$ aura.
  • In the third round, the amount of aura you lose is $2$.
  • In the following rounds, the amount of aura you lose is $2, 4, 5, 9, 6, 9, 13$ respectively.
  • 第一轮中,$a_1 = 3$ 且 $b_1 = 53$,因此你会损失 $13 = \min(\lvert 3 - 40 \rvert, \lvert 53 - 40 \rvert)$ 点灵气。
  • 第二轮中,$a_2 = 36$ 且 $b_2 = 49$,因此你会损失 $4 = \min(\lvert 36 - 40 \rvert, \lvert 49 - 40 \rvert)$ 点灵气。
  • 第三轮中,你会损失 $2$ 点灵气。
  • 后续各轮中,你会依次损失 $2, 4, 5, 9, 6, 9, 13$ 点灵气。
AI (CI翻译)

The total amount of aura you lose is $67$. Note that this is an example of how the interaction works. To receive an accepted verdict, you must solve the problem without exceeding the aura limit outlined in the statement above.

你损失的灵气总量为 $67$。注意,这只是交互过程的示例。若要获得 Accepted 判定,你必须在不超过题面所述灵气上限的前提下解决问题。AI (CI翻译)

样例

Input #1
1

13

4

2

2

4

5

9

6

9

13
Output #1
3 53

36 49

47 38

1 38

44 32

35 35

31 67

33 46

49 50

20 27
InputCopy OutputCopy
题目信息
标签
暴力
模拟
交互题
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。