BSHEEP  Build the Fence
At the beginning of spring all the sheep move to the higher pastures in the mountains. If there are thousands of them, it is well worthwhile gathering them together in one place. But sheep don't like to leave their grasslands. Help the shepherd and build him a fence which would surround all the sheep. The fence should have the smallest possible length! Assume that sheep are negligibly small and that they are not moving. Sometimes a few sheep are standing in the same place. If there is only one sheep, it is probably dying, so no fence is needed at all...
Input
t [the number of tests <= 100]
[empty line]
n [the number of sheep <= 100000]
x_{1} y_{1} [coordinates of the first sheep]
...
x_{n} y_{n}
[integer coordinates from 10000 to
10000]
[empty line]
[other lists of sheep]
Text grouped in [ ] does not appear in the input file. Assume that sheep are numbered in the input order.
Output
o [length of circumference, rounded to 2 decimal places]
p1 p2 ... pk
[the sheep that are standing in the corners of the fence; the first one should be positioned bottommost and as far to the left as possible, the others ought to be written in anticlockwise order; ignore all sheep standing in the same place but the first to appear in the input file; the number of sheep should be the smallest possible]
[empty line]
[next solutions]
Example
Input: 8 5 0 0 0 5 10 5 3 3 10 0 1 0 0 3 0 0 1 0 2 0 4 0 0 0 0 0 1 1 0 3 0 0 0 1 1 0 6 0 0 1 1 1 1 2 2 3 3 4 4 2 10 0 0 0 7 3 4 2 3 4 3 4 2 0 5 2 3 1 4 Output: 30.00 1 5 3 2 0.00 1 4.00 1 3 3.41 1 4 3 3.41 1 3 2 14.14 2 6 20.00 2 1 26.98 1 2 3 5 4Warning: large Input/Output data, be careful with certain languages
hide comments
[Mayank Pratap]:
20160927 06:38:29
AC in one Go :) THink Simple. 

Sanjit Majumdar:
20160818 17:03:50
Got accepted in 0.45s using Andrew's monotone chain convex hull algorithm 

Sampath Ravolaparthi:
20160201 19:05:15
Hell No.......!!


krypto_phile:
20160119 19:54:17
Easy question. Absolutely straightforward! AC in 1 go :P


kartikay singh:
20160118 09:34:05
Easy convo hull :)


CHANDAN KUMAR:
20160118 08:26:36
My first convex hull problem really enjoying debugging it there are many corner cases but think systematically easy in one go 

Mayank Garg:
20160118 05:03:20
My first convex hull problem ... enjoyed solving and debugging it ;) 

(Tjandra Satria Gunawan)(æ›¾æ¯…æ˜†):
20150808 14:18:23
First time I implemented full version of my own convex hull algo written in C :) 

:
20140622 23:13:01
Beware of I/O cost. iostream, Java I/O etc. will easily add up to 1+ seconds on this data. Some of the data is very large!


Jens Stimpfle:
20140318 17:51:55
Haidar Abboud, if you tackle the problem the right way, there are no special cases to consider (repeatedpoints, lessthan3, allcolinear certainly are not).

Added by:  mima 
Date:  20040601 
Time limit:  7s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: NODEJS PERL6 VB.NET 
Resource:   