QOJ.ac

QOJ

حد الوقت: 10 s حد الذاكرة: 1024 MB مجموع النقاط: 100

#3283. 平行线

الإحصائيات

给定偶数个不同的平面点,考虑将所有点两两配对。只要所有给定的点都恰好与另一个点配对,所有可能的配对方式都需要被考虑。

当连接所有配对点对的线段被画出时,其中一些线段可能彼此平行。你的任务是考虑所有可能的点配对方式,找出平行线对的最大数量。

对于第一个样例输入中给出的四个点的情况,有三种点配对模式,如图 B.1 所示。从左到右,平行线对的数量分别为 0、0 和 1。因此最大值为 1。

图 B.1. 样例输入 1 的所有三种可能配对

对于第二个样例输入中给出的八个点的情况,点可以如图 B.2 所示进行配对。通过这样的点配对,所有四条线段彼此平行。换句话说,六个线对 $(L_1, L_2), (L_1, L_3), (L_1, L_4), (L_2, L_3), (L_2, L_4)$ 和 $(L_3, L_4)$ 都是平行的。因此,在这种情况下,平行线对的最大数量为 6。

图 B.2. 样例输入 2 中平行线对数量最大化的情况

输入格式

输入包含单个测试用例,格式如下:

$m$ $x_1 \ y_1$ $\vdots$ $x_m \ y_m$

第一行包含一个偶数 $m$,表示点的数量 ($2 \le m \le 16$)。接下来的 $m$ 行每行给出点的坐标。第 $i$ 行的整数 $x_i$ 和 $y_i$ ($-1000 \le x_i \le 1000, -1000 \le y_i \le 1000$) 分别表示第 $i$ 个点的 $x$ 坐标和 $y$ 坐标。

所有点的位置各不相同,即对于所有 $i \neq j$,满足 $x_i \neq x_j$ 或 $y_i \neq y_j$。此外,没有三点共线。

输出格式

输出上述平行线对的最大可能数量,占一行。

样例

样例输入 1

4
0 0
1 1
0 2
2 4

样例输出 1

1

样例输入 2

8
0 0
0 5
2 2
2 7
3 -2
5 0
4 -2
8 2

样例输出 2

6

样例输入 3

6
0 0
0 5
3 -2
3 5
5 0
5 7

样例输出 3

3

样例输入 4

2
-1000 1000
1000 -1000

样例输出 4

0

样例输入 5

16
327 449
-509 761
-553 515
360 948
147 877
-694 468
241 320
463 -753
-206 -991
473 -738
-156 -916
-215 54
-112 -476
-452 780
-18 -335
-146 77

样例输出 5

12

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.