Time Limit: 2 second(s) | Memory Limit: 32 MB |
Given set of points in the plane, your task is to draw a polygon using the points. You have to use all the points. To be more specific, 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:
You can assume that, no two points will share the same location.
Input
Input starts with an integer T (≤ 100), denoting the number of test cases.
Each case starts with a line containing an integer n (3 ≤ n ≤ 2000), denoting the number of points. The next line contains the co-ordinates of the points. Each point is specified by two integer x y in the range [-104, 104].
Output
For each case, print the case number in a single line first. In the next line print 'Impossible' if no solution can be found. Otherwise print 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. Insert a single space between two integers.
Sample Input | Output for Sample Input |
2 4 0 0 2 0 0 1 1 0 5 0 0 10 0 10 5 5 -1 0 5 | Case 1: 0 3 1 2 Case 2: 2 1 3 0 4 |
Note
This is a special judge problem; wrong output format may cause 'wrong answer'.
题意:
给了n个点,让连成一个多边行。
按照极角排序下,然后搞,就是最好一个点共线的要倒序下。
注意极角排序,第一个点不要排(坑了好久,第一个点排了可能会有问题的)
1 /* *********************************************** 2 Author :kuangbin 3 Created Time :2014/4/22 17:41:27 4 File Name :E:\2014ACM\专题学习\计算几何\凸包\LightOJ1285.cpp 5 ************************************************ */ 6 7 #include8 #include 9 #include 10 #include 11 #include 12 #include 13 #include 14 #include