QOJ.ac

QOJ

Time Limit: 3.0 s Memory Limit: 1024 MB Total points: 100 Hackable ✓

#23645. 索龙上尉

Statistics

奇斯领的 Thrawn 上尉被困在了 Paataatus 的母星上!他掌握了一份至关重要的情报,急需传达给 Ar'alani 上将,但他等不及友方星舰来接应他了。相反,他需要建立一个通信三联体,以便将情报传输给她。该三联体由 3 个部件组成,这 3 个部件彼此之间的非零欧几里得距离必须相等(即位于一个等边三角形的三个顶点上),才能成功传输数据。

然而,奇斯与 Paataatus 之间的政治关系十分紧张,因此 Paataatus 政府不会允许 Thrawn 随意放置三联体的部件。Paataatus 的首都呈边长为 $l$ 的正六边形。它有 $2l + 1$ 条等间距的平行街道(Street),呈自西向东走向,由南向北从 $-l$ 到 $l$ 编号,其中街道 $-l$ 沿着六边形最南侧的边延伸,街道 $l$ 沿着六边形最北侧的边延伸,而街道 $0$ 穿过六边形的中心。

类似地,有 $2l + 1$ 条等间距的平行大道(Avenue),呈自西北向东南走向,由西南向东北从 $-l$ 到 $l$ 编号,其中大道 $-l$ 沿着六边形最西南侧的边延伸,大道 $l$ 沿着六边形最东北侧的边延伸,而大道 $0$ 穿过六边形的中心。

此外,还有 $2l + 1$ 条等间距的平行林荫道(Boulevard),呈自西南向东北走向,由东南向西北从 $-l$ 到 $l$ 编号,其中林荫道 $-l$ 沿着六边形最东南侧的边延伸,林荫道 $l$ 沿着六边形最西北侧的边延伸,而林荫道 $0$ 穿过六边形的中心。

下图是当 $l = 2$ 时首都布局的一个示例:

problem_23645_61db380b8da2c2f06c4fa47d141b47f1.png

在每条街道、大道与林荫道的交汇处,都有一座塔。如果街道编号为 $x$,大道编号为 $y$,林荫道编号为 $z$,那么这座塔的坐标就是 $(x, y, z)$。每座塔都归某位 Paataatus 官员所有。

对 Thrawn 来说幸运的是,在他的职业生涯中,他曾帮助过几位 Paataatus 官员,现在他们愿意回报他,允许他在他们名下的一座塔中架设三联体的一个部件。他们总共拥有 $n$ 座塔,因此 Thrawn 需要从中选出两两距离相等的 3 座塔来建立通信三联体。在做出决定之前,Thrawn 想知道自己所有的可选方案,或者至少知道有多少种方案。请帮他计算选出 3 座塔以建立通信三联体的方案数。

输入格式

第一行包含两个整数 $l$ 和 $n$——首都的边长以及愿意帮助 Thrawn 的塔的数量($1 \le l \le 500$;$1 \le n \le 3 \cdot l \cdot (l + 1) + 1$)。

接下来 $n$ 行,每行包含 3 个整数 $x_i, y_i, z_i$——第 $i$ 座塔的坐标($-l \le x_i, y_i, z_i \le l$)。保证每组坐标都对应某座实际存在的塔,且输入中的所有塔互不相同。

输出格式

输出一个整数——选出符合要求的 3 座塔的方案数。

样例

输入格式 1

2 6
-1 -2 1
2 2 0
-1 1 -2
-1 0 -1
1 1 0
0 1 -1

输出格式 1

1

输入格式 2

1 7
0 1 -1
1 1 0
0 -1 1
1 0 1
-1 -1 0
-1 0 -1
0 0 0

输出格式 2

8

说明

为方便起见,此处附上一张三角形网格:

problem_23645_cd9cbf58f065d9a594a7e17a785b57df.png

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.