#P16788. [蓝桥杯 2026 国 A] 独立三角形
[蓝桥杯 2026 国 A] 独立三角形
Problem Description
There are distinct integer points on a 2D plane. Each point has a -coordinate of either or . Xiaolan wants to connect these points to form as many triangles as possible. Each triangle must satisfy:
- The three vertices must not be collinear.
- Different triangles must not share vertices.
Since when a point is used as a vertex of a triangle, it will be connected to the other two vertices, each point can be an endpoint of at most two line segments.
Now, under the condition that the number of triangles is maximized, find the maximum possible sum of the areas of all triangles. The problem guarantees that this maximum area sum is an integer.
Input Format
The first line contains an integer .
The next lines each contain two integers , representing the coordinates of a point. It is guaranteed that , and no two points coincide.
Output Format
Output one line containing two integers: the maximum number of triangles that can be formed, and the maximum possible sum of areas under that maximum number of triangles.
3
0 1
2 1
1 -1
1 2
6
0 1
3 1
1 1
1 -1
2 -1
4 -1
2 6
Hint
Sample Explanation 1
The three points can form one triangle. Using the two upper points as the base, the base length is , and the distance between the upper and lower lines is , so the area is .
Sample Explanation 2
The -coordinates of the points with are , and the -coordinates of the points with are . At most triangles without shared vertices can be formed.
One optimal plan is: use the two upper points with and as the base of one triangle, with area ; use the two lower points with and as the base of another triangle, also with area . The total area is .
Constraints and Notes for Evaluation
For of the testdata, .
For all testdata, , and .
Translated by ChatGPT 5