#P13005. [GCJ 2022 Finals] Triangles

    ID: 12804 Type: RemoteJudge 15000ms 1024MiB Tried: 0 Accepted: 0 Difficulty: 7 Uploaded By: Tags>贪心计算几何2022Special Judge构造Google Code Jam

[GCJ 2022 Finals] Triangles

题目描述

You are given a set PP of N\mathbf{N} distinct points in the two-dimensional plane. You want to find a maximum set of triangles such that:

  • Each vertex of a triangle in your set is a point from PP and each point in PP is a vertex of at most one triangle in your set.
  • Each triangle in your set has positive area (i.e., its 3 vertices are not collinear).
  • For any two sides of triangles in your set, their intersection is either empty or an endpoint of one of them.
  • For any two triangles in your set, the intersection of the areas strictly inside those triangles is either empty or equal to one of them.

For example, the set of triangles depicted below meets the definition above.

On the other hand, each pair of a yellow and a red triangle in the picture below does not meet the definition.

输入格式

The first line of the input gives the number of test cases, T\mathbf{T}. T\mathbf{T} test cases follow. Each test case starts with a line containing a single integer N\mathbf{N}. Then, N\mathbf{N} lines follow. The ii-th of these lines contains two integers Xi\mathbf{X}_i and Yi\mathbf{Y}_i representing the coordinates of the ii-th point.

输出格式

For each test case, output one line containing Case #x: y, where xx is the test case number (starting from 1) and yy is the maximum size of a set of triangles with the desired properties. Then, output yy more lines. The jj-th of those lines must contain pjp_j qjq_j rjr_j representing that the jj-th triangle in your proposed set has the pjp_j-th, qjq_j-th, and rjr_j-th points in the input as vertices. Points in the input are numbered starting from 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
Case #1: 3
3 4 5
1 7 9
6 2 8
Case #2: 2
2 3 1
6 5 4
Case #3: 0

提示

Sample Case #1 is illustrated below. Notice that there are other valid ways to construct a maximum number of triangles.

Sample Case #2 is illustrated below. As before, there are other valid ways to construct 2 triangles.

In Sample Case #3, the 3 given points are collinear, so it is not possible to make a valid triangle with them.

Limits

  • 1T1001 \leq \mathbf{T} \leq 100.
  • 109Xi109-10^9 \leq \mathbf{X}_i \leq 10^9, for all ii.
  • 109Yi109-10^9 \leq \mathbf{Y}_i \leq 10^9, for all ii.
  • $(\mathbf{X}_i, \mathbf{Y}_i) \neq (\mathbf{X}_j, \mathbf{Y}_j)$, for all iji \neq j.

Test Set 1 (8 Pts, Visible Verdict)

  • 3N123 \leq \mathbf{N} \leq 12.

Test Set 2 (42 Pts, Hidden Verdict)

  • 3N30003 \leq \mathbf{N} \leq 3000.