Problem
Suppose that a polygon is represented by a set of integer coordinates, {(x0, y0), (x1, y1), (x2, y2), …, (xn, yn), (x0, y0)}. Please find the convex hull of the polygon, where a convex hull is the minimum bounding convex polygon and “convex” means the angle between two consecutive edges is less than 180o.
Input file
Input consists of several datasets separated by a blank line. Each dataset contains a sequence of integer coordinates xi, yi, one in each line. All input sequence will contain at least 3 different points.
Output
The output for each dataset should contain a sequence of integer coordinates xi, yi specifying the convex hull, each in a line. The first coordinate of the output sequence must be the first coordinate in the input sequence that belongs to the convex hull. The output sequence must be in counter-cockwise order. Print a blank line between datasets.
Sample Input
|
|
Sample Output
|
|
Solution
題目相當單純要輸出凸包的結果,但是最痛恨的是輸出格式,要求從輸入順序中最小的開始打印。
莫名其妙地弄了很多 WA 出來,也許輸入有重複點的關係,所以把點附加輸入編號可能會有所錯誤,總是暴力查找一個哪個點是要開始打印的即可。
|
|