#P7918. [Kubic] Lines

[Kubic] Lines

Description

In a 2D Cartesian coordinate system, there are nn lines. No three lines intersect at one point, and no two lines coincide. Obviously, these lines form at most n(n1)2\dfrac{n(n-1)}{2} intersection points. You may choose a subset of these lines. A point is considered covered if and only if at least one of the chosen lines passes through it. Find the minimum number of lines to choose so that all intersection points are covered.

Input Format

The first line contains an integer nn.

The next nn lines each contain three integers a,b,ca, b, c, describing a line with equation ax+by+c=0ax+by+c=0.

Note: the input does not guarantee gcd(a,b)=1\gcd(a,b)=1.

Output Format

Output one line with one integer, representing the answer.

3
1 2 3
4 5 6
7 8 10
2

Hint

For 100%100\% of the testdata, 1n1051 \le n \le 10^5, a,b,c109|a|, |b|, |c| \le 10^9, and a,ba, b are not both 00.

Score nn Special Property
Subtask1\operatorname{Subtask}1 1010 20\le 20 None
Subtask2\operatorname{Subtask}2 3030 100\le 100
Subtask3\operatorname{Subtask}3 1010 No special limit ab=0ab=0
Subtask4\operatorname{Subtask}4 5050 None

Sample Explanation

One way is to choose the two lines x+2y+3=0x+2y+3=0 and 4x+5y+6=04x+5y+6=0.

It can be proven that there is no better solution.

Translated by ChatGPT 5