2780. Simple Polygon

单点时限: 5.0 sec

内存限制: 256 MB

Write a program that constructs a polygon from a given set of points in the plane. Each point of the set has to be a vertex of the polygon, and the polygon must not have any other vertices. No two line segments of the polygon may have any point in common, except for the middle vertex of two consecutive line segments. For example, given the points on the left-hand side, a valid polygon is shown on the right-hand side:

A valid polygon is guaranteed to exist, and any valid polygon will be accepted as a correct answer. Moreover, no two points will share the same location, and not all points will be collinear.

输入格式

The first line of the input consists of an integer c (1 <= c <= 200), the number of test cases. Then follow the test cases, one per line. Each test case starts with an integer n (3 <= n <= 2 000), the number of given points. Then follow, on the same line, the coordinates of the points. Each point is specified by two integers x and y in the range -10 000 to 10 000, inclusively.

输出格式

For each test case, print a single line containing a permutation of the numbers 0 to n - 1. Each of these numbers represents the index of a point, in the same order as given in the input. When drawing line segments between consecutive points in the order given by this permutation, the result must be a valid polygon.

样例

Input
2
4 0 0 2 0 0 1 1 0
5 0 0 10 0 10 5 5 -1 0 5
Output
0 3 1 2
3 1 2 4 0

4 人解决,5 人已尝试。

7 份提交通过,共有 10 份提交。

6.9 EMB 奖励。

创建: 15 年,1 月前.

修改: 6 年,11 月前.

最后提交: 1 年,1 月前.

来源: NWERC 2009

题目标签