Triangles
InterviewTime limit1sMemory limit1024 MB
Given N named points with integer coordinates, list every triple of points that is not collinear, with the names in input order.
- Level
Easy2 of 10
- Topics
- Brute force, Geometry
- Solved
- No attempts yet
Problem
Given points in the plane, each with a name and coordinates. Write a program named triangles that finds all triangles that can be formed with three of the given points as vertices.
Input
The first line of standard input contains the integer , the number of points. Each of the next lines contains a name, the x-coordinate, and the y-coordinate of one point, in that order. A name is a single uppercase Latin letter. Both coordinates are integers in the range .
Output
On consecutive lines of standard output, print the names of the three points that form each triangle, separated by one space. List the vertices of each triangle in the order their names appear in the input. If the points form no triangle, print the text "No triangles."