POJ 1328 Radar Installation Greedy

Source: Internet
Author: User
Tags radar

Main topic:
Suppose there is an infinitely long coastline with N islands above the coastline. There are radars on the coastline, each radar can detect a circle with a radius of R, and the island can be detected by radar only when the distance between an island and the radar is less than or equal to R. gives the coordinates of all islands and the radius of the radar. The minimum number of radars required to make all islands detectable.

The ABCD in the figure is the location of the island. Assuming that the radius of the subject is 2 (conforming to the coordinate system), then the a point coordinate is () and so on.
In the title, record the coordinates of each point and add a new marker variable to mark whether it has been accessed.


Stores the intersection of the red circle and the x-axis in the graph. First, the sorting criteria are the order of the red circle and the left intersection of the x-axis.
, if the left intersection (J1 Point) of the B point circle (and so called) is to the left of the right intersection of the point Circle (E1), then the B point must be covered within the a point circle. Then, if the left intersection of the D-point circle (not shown in the figure) is right at the right intersection of the point circle (not marked), the D point is not in the A-point circle.

#include <iostream>#include <cmath>#include <algorithm>using namespace STD;structpoint{DoubleLeft, right;} dp[1050];intSumintCMP (point A, point B) {returnA.left<b.left;}voidSolveintN) {sort (DP, DP+N, CMP); sum=1;Double STD;STD=dp[0].right; for(intI=1; i<n; ++i) {if(dp[i].left>STD) {sum++;STD=dp[i].right; }Else if(dp[i].right<STD)        {STD=dp[i].right; }    }}intMain () {intN, R, X, y;intt=1; while(Cin>>n>>r&& (n+r!=0))    {intI, fail=0; for(i=0; i<n; i++) {Cin>>x>>y;if(Y>r) fail=1;Else{DoubleL=sqrt((Double) (R*r-y*y));                Dp[i].left=x-l;            Dp[i].right=x+l; }        }if(fail) {sum=-1;cout<<"Case"<<t++<<": "<<sum<<endl; }Else{solve (n);cout<<"Case"<<t++<<": "<<sum<<endl; }    }}

POJ 1328 Radar Installation Greedy

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.