#P15617. [ICPC 2022 Jakarta R] Magical Barrier

[ICPC 2022 Jakarta R] Magical Barrier

题目描述

There are NN power sources, numbered from 1 to NN, scattered around the ICPC Kingdom. Power source ii is uniquely located at coordinate (Xi,Yi)(X_i, Y_i) in a 2D Cartesian plane such that there are no three power sources located in a straight line.

For each pair of distinct power sources ii and jj that satisfies 1i<jN1 \leq i < j \leq N, a magical barrier forms as a line segment that spans from (Xi,Yi)(X_i, Y_i) to (Xj,Yj)(X_j, Y_j).

You noticed a strange phenomenon. When two distinct magical barriers are intersecting, then both magical barriers are somewhat strengthened. To simplify things, you define the strength of a magical barrier bb as the number of magical barriers other than bb that intersects with bb. Two distinct magical barriers are intersecting if and only if there exists exactly one point (x,y)(x, y) that lies on both magical barriers while none of the NN power sources are located at (x,y)(x, y).

You want to find the strength of the strongest magical barrier in the ICPC Kingdom.

输入格式

Input begins with an integer NN (2N10002 \leq N \leq 1000) representing the number of power sources. Each of the next NN lines contains 2 integers XiX_i YiY_i (109Xi,Yi109-10^9 \leq X_i, Y_i \leq 10^9) representing the location of power source ii. It is guaranteed that the location of each power source is unique, and there are no three power sources located in a straight line.

输出格式

Output an integer in a single line representing the strength of the strongest magical barrier.

6
0 0
0 6
6 0
6 6
1 4
1 2
3
2
0 0
0 1
0
4
-3 0
3 0
0 3
0 1
0
4
0 0
0 1
1 0
1 1
1

提示

Explanation for the sample input/output #1

Let i,j\langle i, j \rangle be the magical barrier that spans from power source ii to power source jj.

One of the strongest magical barriers is 1,4\langle 1, 4 \rangle with a strength of 33. The 33 magical barriers that intersect with 1,4\langle 1, 4 \rangle are 2,3\langle 2, 3 \rangle, 3,6\langle 3, 6 \rangle, and 3,5\langle 3, 5 \rangle. Note that the magical barrier 2,3\langle 2, 3 \rangle also has a strength of 33.

Explanation for the sample input/output #2

The only magical barrier is 1,2\langle 1, 2 \rangle with a strength of 00.

Explanation for the sample input/output #3

All magical barriers have a strength of 00.

Explanation for the sample input/output #4

The strongest magical barrier is either 1,4\langle 1, 4 \rangle or 2,3\langle 2, 3 \rangle, which intersects each other at (0.5,0.5)(0.5, 0.5).