CCO '99 P4 - Maple Roundup

View as PDF

Submit solution

Points: 10
Time limit: 2.0s
Memory limit: 64M

Problem types
Canadian Computing Competition: 1999 Stage 2, Day 2, Problem 1

An Elmira area maple syrup producer was selected as the winner of this year's CCC (Canadian Confectionery Competition) and the judge wants to place a blue ribbon around the sugar bush. To do this, she finds the most northerly tree (if there is more than one most northerly tree, any one will do) and stands at the position of that tree, facing due East. She then turns to the right until she is facing another tree, and walks to that tree in a straight line, measuring the distance. Once again she turns right until she faces a tree, and walks to it. At each step she chooses the tree that involves turning the least angle to the right, continuing until the starting tree is reached. The total distance travelled is the length of ribbon required. Your task is to calculate this length.

Input Specification

The input to the program will consist of a line containing an integer m followed by m data sets. Each data set consists of a line containing an integer 1 < n < 100, the number of trees in the bush, and this is followed by n lines each with an ordered pair (x, y) of integers which give the location of a tree on the Cartesian grid. You may assume that the y-axis points North while the x-axis points East.

Output Specification

For each test case, the output from the program is the length of ribbon, to 2 decimal places, that can enclose every tree.

Sample Input

2
3
-1 1
1 1
1 -1
5
1 0
2 2
2 3
3 1
-1 2

Sample Output

6.83
10.46

Comments

There are no comments at the moment.