#P13217. [GCJ 2015 #1A] Logging

    ID: 15087 远端评测题 5000~20000ms 1024MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>计算几何2015凸包极角排序Google Code Jam

[GCJ 2015 #1A] Logging

题目描述

A certain forest consists of NN 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 (Xi,Yi)(X_i, Y_i), 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.

输入格式

The first line of the input gives the number of test cases, TT. TT test cases follow; each consists of a single line with an integer NN, the number of trees, followed by NN lines with two space-separated integers XiX_i and YiY_i, the coordinates of each tree. No two trees will have the same coordinates.

输出格式

For each test case, output one line containing "Case #xx:", followed by NN lines with one integer each, where line ii contains the number of trees that the squirrel living in tree ii would need to cut down.

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
Case #1:
0
0
0
0
1
Case #2:
0
0
0
0
3
0
0
0
0

提示

Sample Explanation

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 00. Since one tree needs to be cut down for the fifth tree to be on the boundary, the fifth squirrel writes down 11.

Limits

  • 106Xi,Yi106-10^6 \leq X_i, Y_i \leq 10^6.

Small dataset

  • Time limit: 240 5 seconds.
  • 1T1001 \leq T \leq 100.
  • 1N151 \leq N \leq 15.

Large dataset

  • Time limit: 480 20 seconds.
  • 1T141 \leq T \leq 14.
  • 1N30001 \leq N \leq 3000.