QOJ.ac

QOJ

時間限制: 6 s 記憶體限制: 1024 MB 總分: 100

#2173. 我们的向量是什么,维克多?

统计

向量嵌入是机器学习系统中的常用工具。复杂的现实世界概念(例如字典中的单词)被映射到实数向量上。如果嵌入训练得当,相关的概念在向量空间中会保持接近,因此诸如“这两个词是同义词吗?”之类的问题可以简化为直接的数学测试。

你受雇于 Ye Olde 冰淇淋店来为口味创建嵌入模型,以便在某种冰淇淋口味售罄时,他们可以向顾客推荐相关的口味。在六个云数据中心训练了四个月后,你终于得到了完美的口味模型!你准备好彻底改变你所在街道,甚至是你所在社区的冰淇淋行业了!然而,直到你不小心把一些免费的冰淇淋滴在了键盘上,删除了那一半的数据。冰淇淋店负担不起重新训练模型所需的 300 亿卢布,所以你陷入了麻烦。

幸运的是,你手头还有各种训练结果。对于一个已删除的向量,训练数据告诉了你它与一些已知口味向量的接近程度。向量 $A$ 和 $B$ 的接近程度就是标准的欧几里得距离度量(即向量 $A - B$ 的长度)。编写一个工具来重建与训练结果一致的嵌入。

输入格式

第一行包含两个整数 $d$ 和 $n$,其中 $d$ ($1 \le d \le 500$) 是向量的维度,$n$ ($1 \le n \le 500$) 是你想要重建的已删除嵌入向量的训练结果数量。接下来的 $n$ 行,每行描述一个训练结果,包含 $d + 1$ 个数字 $x_1, \dots, x_d$ 和 $e$。在训练结果中,$x_1, \dots, x_d$ ($-100 \le x_i \le 100$) 是已知向量的坐标,$e$ ($0 \le e \le 5\,000$) 是该向量到已删除向量的欧几里得距离。

你的提交将仅使用下面给出的样例输入以及根据以下过程生成的输入进行测试。首先,选择 $d$ 和 $n$。然后,随机选择 $n$ 个输入向量和 1 个输出向量,每个向量的维度均为 $d$。$d \cdot (n + 1)$ 个坐标是独立且均匀分布在区间 $[-100, 100]$ 内的。接下来,计算每个输入向量到输出向量的欧几里得距离。最后,丢弃输出向量。计算使用双精度浮点数。使用此过程获得的数字在输入中以小数点后 17 位显示。

输出格式

输出 $d$ 个值,即任何到每个训练向量的距离都符合给定距离的向量的坐标,绝对误差或相对误差最多为 $10^{-5}$。

样例

样例输入 1

2 3
0 0 2.5
3 0 2.5
1.5 0.5 2.5

样例输出 1

1.5 -2

样例输入 2

2 2
0 0 2
4 -4 6

样例输出 2

1.414213562373 1.414213562373

样例输入 3

4 3
0 1 2 3 2
1 2 -1 7 5
1 0.3 3.4 1.2 3.3

样例输出 3

1 2 3 4

Ice cream flavors

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.