QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 2048 MB Total points: 100 Interactive

#15622. Astral Geometry

Statistics

作为一名年轻的天文学家,你对一组具有独特特征的恒星的空间排列很感兴趣。了解这些信息可能有助于理解早期宇宙的宇宙学。你可以使用专门的仪器进行测量。

该仪器使用其自身的三维笛卡尔坐标系,其中原点 $(0, 0, 0)$ 设在地球上,恒星的位置被建模为格点(坐标均为整数的点)。你已经知道了所有感兴趣的恒星到地球的距离,但它们的方向未知。

在单次测量中,你指定两颗不同的恒星,仪器会报告它们之间的距离。注意,仪器不会报告恒星的绝对或相对方向。

在有限的测量次数内,确定所有恒星对之间的距离。

交互

输入的第一行包含一个整数 $n$,即感兴趣的恒星数量($2 \le n \le 100$)。恒星编号从 1 到 $n$。第二行包含 $n$ 个整数。其中第 $i$ 个整数是恒星 $i$ 到原点的平方距离。保证所有恒星的坐标均为整数,且每个坐标都在 $-4000$ 到 $4000$(含)之间。没有两颗恒星处于相同位置。没有恒星位于原点。

读取这两行后,你可以开始测量。要测量恒星 $i$ 和 $j$ 之间的距离,请输出一行格式为 “measure $i$ $j$” 的内容,其中 $i$ 和 $j$ 是 $1$ 到 $n$ 之间(含)的相异整数。作为响应,你将获得一行包含一个整数的输入,表示恒星 $i$ 和 $j$ 之间的平方距离。你最多可以进行 300 次测量。

当你确定了所有恒星对之间的距离后,输出一行仅包含 answer 的内容,随后输出 $n-1$ 行,格式如下:

$d_{1,2} \ d_{1,3} \ \dots \ d_{1,n}$ $d_{2,3} \ \dots \ d_{2,n}$ $\vdots$ $d_{n-1,n}$

其中 $d_{i,j}$ ($1 \le i < j \le n$) 是一个整数,表示恒星 $i$ 和 $j$ 之间的平方距离。注意,你不需要确定恒星的坐标。输出这些行后,交互停止,你的程序必须终止,不得有任何额外输出。

如果你的输出不符合上述规范,或者测量次数超过 300 次,你的提交将被判为错误答案。

恒星的坐标在交互开始前是固定的;它们在交互过程中不会改变。

你将获得一个用于本地测试的命令行工具。更多详细信息,请参考竞赛系统中的说明。

样例

样例输入 1

3
1 11 4

样例输出 1

measure 1 2
14
measure 2 3
11
measure 3 1
9
answer
14 9
11

说明 1

在样例交互 1 中,恒星的坐标可以是: 恒星 1 位于 $(1, 0, 0)$, 恒星 2 位于 $(-1, -1, 3)$,以及 * 恒星 3 位于 $(-2, 0, 0)$。

恒星 1 和 2 之间的距离为 $\sqrt{14}$。在第一次测量中,返回了平方距离 14。

图 F.1. 样例交互 1 的示意图

样例输入 2

4
47944017 47920034 47960009 47968006

样例输出 2

answer
191728099 2 191824043
191760077 12
191856029

说明 2

在样例交互 2 中,恒星的坐标可以是: 恒星 1 位于 $(-3998, -3998, -3997)$, 恒星 2 位于 $(3997, 3997, 3996)$, 恒星 3 位于 $(-3999, -3998, -3998)$,以及 恒星 4 位于 $(3999, 3999, 3998)$。

样例输入 3

5
1 4 9 50 149

样例输出 3

answer
5 10 45 162
13 38 181
29 206
371

说明 3

在样例交互 3 中,恒星的坐标可以是: 恒星 1 位于 $(1, 0, 0)$, 恒星 2 位于 $(0, -2, 0)$, 恒星 3 位于 $(0, 0, 3)$, 恒星 4 位于 $(3, -4, 5)$,以及 * 恒星 5 位于 $(-6, 7, -8)$。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.