QOJ.ac

QOJ

时间限制: 15 s - 15 s 内存限制: 1024 MB 总分: 50

#4515. 三角形

统计

给定一个二维平面上的 $N$ 个不同点集 $P$。 你希望找到一个最大的三角形集合,使得:

  • 集合中每个三角形的顶点都是 $P$ 中的点,且 $P$ 中的每个点至多是一个三角形的顶点。
  • 集合中每个三角形的面积都为正(即其 $3$ 个顶点不共线)。
  • 集合中任意两条三角形的边,它们的交集要么为空,要么是其中一条边的端点。
  • 集合中任意两个三角形,它们内部区域的交集要么为空,要么等于其中一个三角形。

例如,下图中展示的三角形集合满足上述定义。

Examples of triangles that meet the definition.

另一方面,下图中每一对黄色和红色的三角形都不满足上述定义。

Several pairs of triangles that do not meet the definition.

输入格式

输入的第一行包含测试用例的数量 $T$。接下来有 $T$ 个测试用例。 每个测试用例的第一行包含一个整数 $N$。接下来的 $N$ 行中,第 $i$ 行包含两个整数 $X_i$ 和 $Y_i$,表示第 $i$ 个点的坐标。

输出格式

对于每个测试用例,输出一行 Case #x: y,其中 $x$ 是测试用例编号(从 1 开始),$y$ 是满足所需属性的三角形集合的最大大小。然后,输出 $y$ 行。其中第 $j$ 行必须包含 $p_j\ q_j\ r_j$,表示你所构造集合中的第 $j$ 个三角形由输入中的第 $p_j$ 个、第 $q_j$ 个和第 $r_j$ 个点作为顶点。输入中的点从 $1$ 开始编号。

数据范围

  • $1 \le T \le 100$
  • $-10^9 \le X_i \le 10^9$,对于所有 $i$
  • $-10^9 \le Y_i \le 10^9$,对于所有 $i$
  • $(X_i, Y_i) \neq (X_j, Y_j)$,对于所有 $i \neq j$

子任务 1

  • $3 \le N \le 12$

子任务 2

  • $3 \le N \le 3000$

样例

输入 1

3
9
8 2
10 2
2 0
0 5
2 3
10 4
10 0
8 3
2 4
7
0 0
0 3
3 0
0 1
1 0
1 1
2 2
3
0 0
0 1
0 2

输出 1

Case #1: 3
3 4 5
1 7 9
6 2 8
Case #2: 2
2 3 1
6 5 4
Case #3: 0

说明

样例 1 如下图所示。请注意,构造最大数量三角形的方法可能不止一种。

Illustration of the input and output of Sample Case #1

样例 2 如下图所示。同样地,构造 $2$ 个三角形的方法可能不止一种。

Illustration of the input and output of Sample Case #2

在样例 3 中,给定的 $3$ 个点共线,因此无法用它们构成有效的三角形。

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.