#C746. Collinear Stars

    ID: 51333 Type: Default 1000ms 256MiB

Collinear Stars

Collinear Stars

You are given a set of points in the 2D plane representing the coordinates of stars. Your task is to identify all unique sets of three stars that lie in a straight line.

Two or more stars are collinear if they lie on the same line. More formally, three points \( (x_1, y_1) \), \( (x_2, y_2) \), \( (x_3, y_3) \) are collinear if the area of the triangle they form is zero, which is equivalent to verifying:

[ (y_2 - y_1) (x_3 - x_2) = (y_3 - y_2) (x_2 - x_1) ]

For each test case, if there is at least one set of three collinear points, output each set (with the points sorted in increasing order by their coordinates) on its own line. If no such sets exist, output "No collinear sets found".

inputFormat

The input is read from standard input (stdin) and is formatted as follows:

  • The first line contains an integer \(T\), the number of test cases.
  • For each test case:
    • The first line contains an integer \(N\), the number of stars.
    • The next \(N\) lines each contain two integers \(x\) and \(y\), representing the coordinate of a star.

All numbers are separated by whitespace.

outputFormat

For each test case, if one or more sets of three collinear stars exist, output each set on a separate line. A collinear set should list the three points in the format (x, y), separated by spaces. Points within each set must be sorted in lexicographical order (first by \(x\), then by \(y\)).

If no collinear set exists for a test case, output the line "No collinear sets found".

The output is written to standard output (stdout). Each printed line may be separated by a newline.

## sample
3
5
1 1
2 2
3 3
1 2
2 3
4
1 1
2 3
3 2
4 4
5
0 0
1 1
2 2
3 3
0 1
(1, 1) (2, 2) (3, 3)

No collinear sets found

(0, 0) (1, 1) (2, 2)

(0, 0) (1, 1) (3, 3)

(0, 0) (2, 2) (3, 3)

(1, 1) (2, 2) (3, 3)

</p>