poj 1106 Transmitters (计算几何,叉积||极角排序)

Transmitters
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 4817   Accepted: 2576

Description

In a wireless network with multiple transmitters sending on the same frequencies, it is often a requirement that signals don’t overlap, or at least that they don’t conflict. One way of accomplishing this is to restrict a transmitter’s coverage area. This problem uses a shielded transmitter that only broadcasts in a semicircle. 

A transmitter T is located somewhere on a 1,000 square meter grid. It broadcasts in a semicircular area of radius r. The transmitter may be rotated any amount, but not moved. Given N points anywhere on the grid, compute the maximum number of points that can be simultaneously reached by the transmitter’s signal. Figure 1 shows the same data points with two different transmitter rotations. 


All input coordinates are integers (0-1000). The radius is a positive real number greater than 0. Points on the boundary of a semicircle are considered within that semicircle. There are 1-150 unique points to examine per transmitter. No points are at the same location as the transmitter. 

Input

Input consists of information for one or more independent transmitter problems. Each problem begins with one line containing the (x,y) coordinates of the transmitter followed by the broadcast radius, r. The next line contains the number of points N on the grid, followed by N sets of (x,y) coordinates, one set per line. The end of the input is signalled by a line with a negative radius; the (x,y) values will be present but indeterminate. Figures 1 and 2 represent the data in the first two example data sets below, though they are on different scales. Figures 1a and 2 show transmitter rotations that result in maximal coverage.

Output

For each transmitter, the output contains a single line with the maximum number of points that can be contained in some semicircle.

Sample Input

Sample Output

Source

 
题意是说,给定一个固定圆心和半径的半圆,问半圆旋转到哪个角度覆盖的点最多。
当点在边界上认为也是在半圆里面。
分析可知,当半圆恰好旋转道某角度使得点在边界上的时候一定不会比对应的最优的情况更坏。
所以我们可以首先剔除掉那些距离圆心距离大于r的点。
然后枚举剩下的每个点,以当前点连接圆心,作为当前圆的半径(这样得到的是两个圆,左边一个右边一个,但我们只考虑一个就好)
看有多少点在当前半圆的同一侧,记录为sum
然后更新所有点得到的sum的最大值即可。
 
不需要极角排序。。。直接枚举就行。。
判断在一侧的方法是,用叉积。 小于0逆时针大于0顺时针。。。嗯。都可以。。。

View Code

 

Posted in ACM

说点什么

您将是第一位评论人!

提醒
wpDiscuz