DMPG '19 B5 - Triangles

View as PDF

Submit solution


Points: 10 (partial)
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

There are N points labelled from 1 to N. The point labelled i is located at (xi,yi). These N points are coloured such that the point labelled i has colour ci. There are only two colours, red or blue. If ci is 1, the point is red and if ci is 2, the point is blue. It is guaranteed that no two have the same coordinates. Can you choose 3 of the N points such that none of the other N3 points lie within the interior of the (possibly degenerate) triangle formed by the 3 points and such that the colours of the 3 points are not all the same? A point on the boundary of the triangle is not considered within the interior of the triangle for this problem. In particular, choosing 3 collinear points will guarantee no other points in its interior.

Constraints

1ci2 for all 1iN
1xi,yi106 for all 1iN
3N200000

Input Specification

The first line contains a single integer, N.
The next N lines each contain three space-separated integers, xi, yi, and ci.

Output Specification

If it is not possible to find 3 such points, output -1. Otherwise, print three space-separated integers i j k on a single line representing the three points chosen. If there are multiple possibilities, any triplet will be accepted. The triplet does not need to be written in any particular order.

Sample Input 1

Copy
6
1 1 1
7 7 2
1 7 1
7 1 1
2 3 1
6 5 1

Sample Output 1

Copy
2 3 5

Sample Input 2

Copy
4
1 1 1
1 2 2
1 3 1
1 4 1

Sample Output 2

Copy
1 2 4

Comments

There are no comments at the moment.