【codejam2015 Round1A】C Logging

博客介绍了Codejam2015 Round1A的问题,森林中的松鼠想要知道需要移除多少棵树,自己的树才能位于森林边界上。问题转化为计算几何中的点成为凸包边界的条件,即找到过该点的一条直线,使得这条直线一侧没有其他点。解决方案包括以点为原点极角排序其他点,并进行线性扫描计算。文章提供了问题背景、限制条件、样例输入输出及极角排序方法。
摘要由CSDN通过智能技术生成

Problem

A certain forest consists of N 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), 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

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

Output

For each test case, output one line containing “Case #x:”, followed by N lines with one integer each, where line i contains the number of trees that the squirrel living in tree i would need to cut down.

Limits

-106 ≤ Xi, Yi ≤ 106.
Small dataset

1 ≤ T ≤ 100.
1 ≤ N ≤ 15.
Large dataset

1 ≤ T ≤ 14.
1 ≤ N ≤ 3000.
Sample

Input

Output

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
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 0. Since one tree needs to be cut down for the fifth tree to be on

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值