CF1375I.Cubic Lattice

NOI/NOI+/CTSC

通过率:0%

时间限制:4.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A cubic lattice LL in 33-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 r⃗1,r⃗2,r⃗3∈Z3\vec r_1, \vec r_2, \vec r_3 \in \mathbb{Z}^3 are some integer vectors such that:

  • r⃗1\vec r_1, r⃗2\vec r_2 and r⃗3\vec r_3 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⃗\vec a \cdot \vec b is a dot product of vectors a⃗\vec a and b⃗\vec b.
  • r⃗1\vec r_1, r⃗2\vec r_2 and r⃗3\vec r_3 all have the same length: $$|\vec r_1| = |\vec r_2| = |\vec r_3| = r$$

You're given a set A=a⃗1,a⃗2,…,a⃗nA={\vec a_1, \vec a_2, \dots, \vec a_n} of integer points, ii-th point has coordinates ai=(xi;yi;zi)a_i=(x_i;y_i;z_i). Let gi=gcd⁡(xi,yi,zi)g_i=\gcd(x_i,y_i,z_i). It is guaranteed that gcd⁡(g1,g2,…,gn)=1\gcd(g_1,g_2,\dots,g_n)=1.

You have to find a cubic lattice LL such that A⊂LA \subset L and rr is the maximum possible.

三维欧几里得空间中的一个立方晶格 LL 是如下定义的一组点:

L={u⋅r⃗1+v⋅r⃗2+w⋅r⃗3}u,v,w∈ZL=\{u \cdot \vec r_1 + v \cdot \vec r_2 + w \cdot \vec r_3\}_{u, v, w \in \mathbb Z}

其中 r⃗1,r⃗2,r⃗3∈Z3\vec r_1, \vec r_2, \vec r_3 \in \mathbb{Z}^3 是某些整数向量,且满足:

  • r⃗1\vec r_1、r⃗2\vec r_2 与 r⃗3\vec r_3 两两正交:

    r⃗1⋅r⃗2=r⃗1⋅r⃗3=r⃗2⋅r⃗3=0\vec r_1 \cdot \vec r_2 = \vec r_1 \cdot \vec r_3 = \vec r_2 \cdot \vec r_3 = 0

    这里 a⃗⋅b⃗\vec a \cdot \vec b 表示向量 a⃗\vec a 与 b⃗\vec b 的点积。
  • r⃗1\vec r_1、r⃗2\vec r_2 与 r⃗3\vec r_3 的长度均相等:

    ∣r⃗1∣=∣r⃗2∣=∣r⃗3∣=r|\vec r_1| = |\vec r_2| = |\vec r_3| = r

给定一组整数点 A={a⃗1,a⃗2,…,a⃗n}A=\{\vec a_1, \vec a_2, \dots, \vec a_n\},其中第 ii 个点的坐标为 a⃗i=(xi;yi;zi)\vec a_i=(x_i;y_i;z_i)。令 gi=gcd⁡(xi,yi,zi)g_i=\gcd(x_i,y_i,z_i)。题目保证 gcd⁡(g1,g2,…,gn)=1\gcd(g_1,g_2,\dots,g_n)=1。

你需要找出一个立方晶格 LL,使得 A⊂LA \subset L,且 rr 尽可能大。

输入格式

First line contains single integer nn (1≤n≤1041 \leq n \leq 10^4) — the number of points in AA.

The ii-th of the following nn lines contains integers xix_i, yiy_i, ziz_i (0<xi2+yi2+zi2≤10160 \lt x_i^2 + y_i^2 + z_i^2 \leq 10^{16}) — coordinates of the ii-th point.

It is guaranteed that gcd⁡(g1,g2,…,gn)=1\gcd(g_1,g_2,\dots,g_n)=1 where gi=gcd⁡(xi,yi,zi)g_i=\gcd(x_i,y_i,z_i).

第一行包含一个整数 nn(1≤n≤1041 \leq n \leq 10^4)——集合 AA 中点的个数。

接下来的 nn 行中,第 ii 行包含三个整数 xix_i、yiy_i、ziz_i(0<xi2+yi2+zi2≤10160 \lt x_i^2 + y_i^2 + z_i^2 \leq 10^{16})——第 ii 个点的坐标。

保证 gcd⁡(g1,g2,…,gn)=1\gcd(g_1,g_2,\dots,g_n)=1,其中 gi=gcd⁡(xi,yi,zi)g_i=\gcd(x_i,y_i,z_i)。

输出格式

In first line output a single integer r2r^2, the square of maximum possible rr.

In following 33 lines output coordinates of vectors r⃗1\vec r_1, r⃗2\vec r_2 and r⃗3\vec r_3 respectively.

If there are multiple possible answers, output any.

第一行输出一个整数 r2r^2,即最大可能的 rr 的平方。

接下来的 33 行分别输出向量 r⃗1\vec r_1、r⃗2\vec r_2 和 r⃗3\vec r_3 的坐标。

若存在多个可能的答案,输出任意一个即可。

输入输出样例

  • 输入#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测评打分。不知道怎么写?

首页