QOJ.ac

QOJ

时间限制: 60 s 内存限制: 256 MB 总分: 100

#11396. 方向相似性

统计

向量具有方向,两个向量之间存在夹角。给定一组三维向量,你的任务是找出其中夹角最小的一对向量。

输入格式

输入包含一系列数据集。每个数据集指定了一组三维向量,其中一些直接在数据集中给出,另一些则通过下述过程生成。

每个数据集的格式如下:

$m \ n \ S \ W$ $x_1 \ y_1 \ z_1$ $x_2 \ y_2 \ z_2$ $\vdots$ $x_m \ y_m \ z_m$

第一行包含四个整数 $m, n, S$ 和 $W$。

整数 $m$ 是直接在数据集中指定的向量个数。从第二行开始,有 $m$ 行,每行包含一个向量的三个分量。第 $i$ 行表示向量 $v_i = (x_i, y_i, z_i)$。所有向量分量均为小于等于 $100$ 的正整数。

整数 $n$ 是通过以下过程生成的向量个数:

int g = S;
for(int i=m+1; i<=m+n; i++) {
x[i] = (g/7) %100 + 1;
y[i] = (g/700) %100 + 1;
z[i] = (g/70000)%100 + 1;
if( g%2 == 0 ) { g = (g/2); }
else { g = (g/2) ^ W; }
}

对于 $i = m+1, \dots, m+n$,集合中的第 $i$ 个向量 $v_i$ 具有由上述过程生成的三个分量 $x[i], y[i]$ 和 $z[i]$。

这里,$S$ 和 $W$ 的值是第一行给出的参数 $S$ 和 $W$。你可以假设 $1 \le S \le 10^9$ 且 $1 \le W \le 10^9$。

向量总数满足 $2 \le m+n \le 12 \times 10^4$。注意,在单个数据集中,完全相同的向量可能会被指定两次或多次。

包含四个零的行表示输入结束。所有数据集中 $m+n$ 的总和不超过 $16 \times 10^5$。

输出格式

对于每个数据集,输出指定集合中夹角最小的非零夹角向量对。保证至少存在两个方向不同的向量。

向量应由其三个分量表示。向量对 $v_a$ 和 $v_b$ 的输出格式如下:

$x_a \ y_a \ z_a \ x_b \ y_b \ z_b$

两个向量 $(x_a, y_a, z_a)$ 和 $(x_b, y_b, z_b)$ 按字典序排序,即如果 $x_a < x_b$,或者 $x_a = x_b$ 且 $y_a < y_b$,或者 $x_a = x_b, y_a = y_b$ 且 $z_a < z_b$,则 $v_a < v_b$。输出向量对时,应先输出字典序较小的向量。

如果有多对向量的夹角相等且均为最小,则输出其中字典序最小的向量对。向量对 $(v_i, v_j)$ 小于 $(v_k, v_l)$ 的条件是 $v_i < v_k$,或者 $v_i = v_k$ 且 $v_j < v_l$。

样例

样例输入 1

4 0 2013 1124
1 1 1
2 2 2
2 1 1
1 2 1
2 100 131832453 129800231
42 40 46
42 40 46
0 100000 7004674 484521438
0 0 0 0

样例输出 1

1 1 1 1 2 1
42 40 46 83 79 91
92 92 79 99 99 85

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.