CF1375I.Cubic Lattice
NOI/NOI+/CTSC
通过率:0%
时间限制:4.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A cubic lattice L in 3-dimensional euclidean space is a set of points defined in the following way: $$L=\{u \cdot \vec r_1 + v \cdot \vec r_2 + w \cdot \vec r_3\}_{u, v, w \in \mathbb Z}$$ Where r1,r2,r3∈Z3 are some integer vectors such that:
- r1, r2 and r3 are pairwise orthogonal: $$\vec r_1 \cdot \vec r_2 = \vec r_1 \cdot \vec r_3 = \vec r_2 \cdot \vec r_3 = 0$$ Where a⋅b is a dot product of vectors a and b.
- r1, r2 and r3 all have the same length: $$|\vec r_1| = |\vec r_2| = |\vec r_3| = r$$
You're given a set A=a1,a2,…,an of integer points, i-th point has coordinates ai=(xi;yi;zi). Let gi=gcd(xi,yi,zi). It is guaranteed that gcd(g1,g2,…,gn)=1.
You have to find a cubic lattice L such that A⊂L and r is the maximum possible.
三维欧几里得空间中的一个立方晶格 L 是如下定义的一组点:
L={u⋅r1+v⋅r2+w⋅r3}u,v,w∈Z
其中 r1,r2,r3∈Z3 是某些整数向量,且满足:
- r1、r2 与 r3 两两正交:
r1⋅r2=r1⋅r3=r2⋅r3=0
这里 a⋅b 表示向量 a 与 b 的点积。 - r1、r2 与 r3 的长度均相等:
∣r1∣=∣r2∣=∣r3∣=r
给定一组整数点 A={a1,a2,…,an},其中第 i 个点的坐标为 ai=(xi;yi;zi)。令 gi=gcd(xi,yi,zi)。题目保证 gcd(g1,g2,…,gn)=1。
你需要找出一个立方晶格 L,使得 A⊂L,且 r 尽可能大。
输入格式
First line contains single integer n (1≤n≤104) — the number of points in A.
The i-th of the following n lines contains integers xi, yi, zi (0<xi2+yi2+zi2≤1016) — coordinates of the i-th point.
It is guaranteed that gcd(g1,g2,…,gn)=1 where gi=gcd(xi,yi,zi).
第一行包含一个整数 n(1≤n≤104)——集合 A 中点的个数。
接下来的 n 行中,第 i 行包含三个整数 xi、yi、zi(0<xi2+yi2+zi2≤1016)——第 i 个点的坐标。
保证 gcd(g1,g2,…,gn)=1,其中 gi=gcd(xi,yi,zi)。
输出格式
In first line output a single integer r2, the square of maximum possible r.
In following 3 lines output coordinates of vectors r1, r2 and r3 respectively.
If there are multiple possible answers, output any.
第一行输出一个整数 r2,即最大可能的 r 的平方。
接下来的 3 行分别输出向量 r1、r2 和 r3 的坐标。
若存在多个可能的答案,输出任意一个即可。
输入输出样例
输入#1
2 1 2 3 1 2 1
输出#1
1 1 0 0 0 1 0 0 0 1
输入#2
1 1 2 2
输出#2
9 2 -2 1 1 2 2 -2 -1 2
输入#3
1 2 5 5
输出#3
9 -1 2 2 2 -1 2 2 2 -1
输入解题思路,AI测评打分。不知道怎么写?