QOJ.ac

QOJ

Time Limit: 10 s Memory Limit: 1024 MB Total points: 100

#3283. 平行な直線

Statistics

平面上の互いに異なる点が偶数個与えられます。すべての点を二つずつの組にすることを考えます。各点がちょうど一つの他の点と組になる、すべての可能な組分けを考慮します。

各組の二点を結ぶ直線を引くと、一部の直線は互いに平行になることがあります。すべての可能な組分けを考慮し、平行な直線の組の個数の最大値を求めてください。

四つの点がある最初の入力例では、図 B.1 に示す三通りの組分けがあります。平行な直線の組の個数は左から $0$、$0$、$1$ なので、最大値は $1$ です。

problem_3283_11ee6be3bf9f53a5b0f6eb6b3dc59528.png

図 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$ です。

入力

入力は次の形式の一つのテストケースからなります。

$$\begin{gathered}m\\x_1\quad y_1\\\vdots\\x_m\quad y_m\end{gathered}$$

problem_3283_a32f127b92ca4c9aee6d4da1aba26b0a.png

図 B.2. 入力例 2 の平行な直線の組の個数の最大化

最初の行には、点の個数を表す偶数の整数 $m$ が含まれます ($2\le m\le16$)。続く $m$ 行は各点の座標を与えます。その $i$ 行目の整数 $x_i,y_i$ ($-1000\le x_i\le1000$、$-1000\le y_i\le1000$) は、それぞれ $i$ 番目の点の $x$ 座標と $y$ 座標を表します。

点の位置はすべて異なります。すなわち、すべての $i\ne j$ について $x_i\ne x_j$ または $y_i\ne 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.