Parallel Lines
Time limit10sMemory limit512 MB
Given up to 16 distinct points, pair them up to maximize the number of parallel pairs among the drawn segments.
- Level
Hard8 of 10
- Topics
- Bit manipulation, Dynamic programming, Geometry, Combinatorics
- Solved
- No attempts yet
Problem
You are given an even number of distinct points on the plane. Couple all of the points into pairs so that every point is coupled with exactly one other point, and consider every such coupling.
Draw the segment that connects the two points of each couple. Some of the drawn segments are parallel to others. Find the maximum number of parallel segment pairs over all possible couplings.
For the four points , , and there are three couplings, shown in Figure B.1. The numbers of parallel segment pairs are 0, 0 and 1, from the left, so the maximum is 1.

Figure B.1. All three possible couplings of the four points
Eight points can be coupled as shown in Figure B.2. With that coupling all four segments are parallel to one another, so the six pairs , , , , and are parallel and the maximum is 6.

Figure B.2. A coupling of eight points that maximizes the number of parallel segment pairs
Input
The input consists of a single test case of the following format.
m
x1 y1
.
.
.
xm ym
The first line contains an even integer , the number of points (). Each of the following lines gives the coordinates of one point. The integers and in the -th of those lines are the x-coordinate and the y-coordinate of the -th point (, ).
All points are at different positions, that is, or holds for all . No three points lie on a single line.
Output
Print the maximum number of parallel segment pairs in one line.