A certain forest consists of trees, each of which is inhabited by a squirrel.
The boundary of the forest is the convex polygon of smallest area which contains every tree, as if a giant rubber band had been stretched around the outside of the forest.
Formally, every tree is a single point in two-dimensional space with unique coordinates , and the boundary is the convex hull of those points.
Some trees are on the boundary of the forest, which means they are on an edge or a corner of the polygon. The squirrels wonder how close their trees are to being on the boundary of the forest.
One at a time, each squirrel climbs down from its tree, examines the forest, and determines the minimum number of trees that would need to be cut down for its own tree to be on the boundary. It then writes that number down on a log.
Determine the list of numbers written on the log.
Input Specification
The first line of the input gives the number of test cases, . test cases follow; each consists of a single line with an integer , the number of trees, followed by lines with two space-separated integers and , the coordinates of each tree. No two trees will have the same coordinates.
Output Specification
For each test case, output one line containing Case #x:
, followed by lines with one integer each, where line contains the number of trees that the squirrel living in tree would need to cut down.
Limits
Memory limit: 1 GB.
.
Small Dataset
Time limit: 60 seconds.
.
.
Large Dataset
Time limit: 120 seconds.
.
.
Sample Input
2
5
0 0
10 0
10 10
0 10
5 5
9
0 0
5 0
10 0
0 5
5 5
10 5
0 10
5 10
10 10
Sample Output
Case #1:
0
0
0
0
1
Case #2:
0
0
0
0
3
0
0
0
0
In the first sample case, there are four trees forming a square, and a fifth tree inside the square. Since the first four trees are already on the boundary, the squirrels for those trees each write down . Since one tree needs to be cut down for the fifth tree to be on the boundary, the fifth squirrel writes down .
Note
This problem has different time limits for different batches. If you exceed the Time Limit for any batch, the judge will incorrectly display >120.000s
regardless of the actual time taken. Refer to the Limits section for batch-specific time limits.
This problem originally had a much higher time limit. However, as reference solutions were much faster, the Time Limit was been reduced accordingly.
Comments