灵气对战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$是当前这场对战的隐藏值。
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]$ 范围之外的值,交互器将停止应答,你会得到 答案错误 的判定。遇到这种情况时,请确保程序立即退出,否则可能会得到任意判定。如果某场对战中损失的灵气总量超过题面所述限制,你也会得到 答案错误 的判定:第一个测试(样例)中限制为 $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:
输出一个值后,别忘了输出换行符并刷新输出缓冲区,否则你会得到 超过空闲时间限制 的判定。可以使用:AI (CI翻译)
fflush(stdout)orcout.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(); - 其他语言请查阅相关文档。
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$点灵气。
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$ 点灵气。请注意,这只是交互过程的一个示例。要获得通过判定,你必须解决本题,并确保灵气损失不超过题面中所述的限制。AI (CI翻译)
样例
1
13
4
2
2
4
5
9
6
9
13
3 53
36 49
47 38
1 38
44 32
35 35
31 67
33 46
49 50
20 27
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。