Maple Roundup
InterviewTime limit1sMemory limit128 MB
Given up to 99 points, find the convex hull by repeatedly turning right through the smallest angle, and output its perimeter rounded to two decimals.
- Level
Medium6 of 10
- Topics
- Geometry, Sorting, Implementation, Brute force
- Solved
- No attempts yet
Problem

A maple syrup producer from the Elmira area has been chosen as this year's winner of the CCC (Canadian Confectionery Competition), and the judge wants to tie a blue ribbon around the sugar bush (the producer's grove of maple trees).
To do this she finds the most northerly tree (if several trees are equally far north, any one of them will do) and stands at that tree facing due East. She then turns to the right until she is facing another tree and walks to it in a straight line, measuring the distance. Once she arrives she again turns right until she faces a tree and walks to it. At every step she chooses the tree that requires turning through the smallest angle to the right, and she continues until she returns to the starting tree.
The total distance she travels is the length of ribbon required. Along the way the ribbon traces the outline that encloses all of the trees. Compute this length.
Input
The first line contains an integer , the number of data sets. Each data set begins with a line containing an integer (), the number of trees in the bush, followed by lines. Each of those lines contains an ordered pair of integers and giving the location of one tree on the Cartesian plane. The -axis points North and the -axis points East.
Output
For each data set, print on its own line the length of ribbon that encloses every tree, rounded to decimal places.