Under construction

Still being built. Things may change

Alignment of the Planets

Interview

Time limit1sMemory limit1024 MB

Summary
Given N grid points, list every triple of points that lie exactly on one line, with IDs sorted within each triple and across the output.
Level

Easy3 of 10

Topics
Geometry, Brute force, Sorting
Solved
No attempts yet

Problem

Actually, this problem is about the alignment of NN (1≤N≤7701 \le N \le 770) cows numbered 11 to NN who are grazing in a field that is about 15000×1500015000 \times 15000 units. Every grazing location is on an integer coordinate in a standard x,yx, y grid, with coordinates in the range 00 to 1500015000.

Bessie looks up and notices that she is exactly lined up with Sara and Julie. She wonders how many groups of three aligned cows exist in the field.

Given the locations of all the cows (no two cows occupy the same location), find every set of three cows that are exactly collinear. Sort the cows in each set by ID number, lowest first. Then sort the sets by their three ID numbers, lowest first, breaking ties by the second and third ID numbers.

Input

The first line contains a single integer NN.

Each of the next NN lines contains two space-separated integers, the xx and yy coordinates of cow ii on line i+1i+1.

Output

The first line contains the number of sets of three cows that are exactly collinear. If four cows are collinear, they form four such sets.

Each following line contains three space-separated cow ID numbers of a collinear set. The lines are sorted as described above. If no collinear sets exist, nothing is printed after the first line.

Examples1

  1. Example 1

    Input
    8
    0 0
    0 4
    1 2
    2 4
    4 3
    4 5
    5 1
    6 5
    
    Expected output
    1
    1 3 4