#P8042. Parallelograms Game
Parallelograms Game
Parallelograms Game
In the game Parallelograms, you are given N points in the plane with distinct coordinates. At each move, you may choose three non-collinear points A, B, and C. Then you construct a unique point D such that the quadrilateral ACBD forms a parallelogram having AB as its diagonal. In mathematical terms, if the points are represented as vectors, the point D is computed as:
[ D = A + B - C ]
After drawing the parallelogram, the point C is moved to the newly constructed point D. During the entire sequence of moves, it is required that the absolute value of all point coordinates does not exceed \(10^9\). Note that even though all points start with distinct coordinates, some points may coincide after several moves.
Your task is to perform at most 2500 moves to ensure that all points end up in the first quadrant (i.e. both coordinates are strictly positive). If there is no valid sequence of moves that achieve this, you must report that no solution exists. You are not required to minimize the number of moves, as long as it does not exceed the limit.
inputFormat
The first line of input contains an integer N, the number of points.
The following N lines each contain two integers x and y representing the coordinates of a point.
outputFormat
If a valid sequence of moves exists, first output an integer K (with 0 ≤ K ≤ 2500
) representing the number of moves. Then output K lines, each containing three distinct integers i, j, and k (1-indexed) indicating that in this move you choose points A (index i), B (index j), and C (index k). After performing these moves, it must be true that all points lie in the first quadrant (i.e. for every point, x > 0 and y > 0).
If no valid sequence exists, simply output -1
.
sample
3
1 2
3 4
5 6
0
</p>