Never trust Ivan (2)

Given n points on the plane p₁…p_(n) no three of which are collinear,
find a permutation of the points p_(i₁)…p_(i_(n)) such that the n
segments
(p_(i₁), p_(i₂)), (p_(i₂), p_(i₃)), …, (p_(i_(n − 1)), p_(i_(n))), (p_(i_(n)), p_(i₁))
form a non-degenerate polygon, that is, one that does not cross itself.

Input

Input consists of several cases, each one with n followed by n points
with integer coordinates not larger than 10⁷ in absolute value. Assume
3 ≤ n ≤ 10⁴, and that no three given points are collinear.

Output

For every case, print a correct polygon constructed from the n points.
If there is more than one solution, print any of them. If there is no
solution, print “Ivan is a troll”.

Problem information

Author: Ivan Geffner

Generation: 2026-01-25T11:20:49.653Z

© Jutge.org, 2006–2026.
https://jutge.org
