本文共 1359 字,大约阅读时间需要 4 分钟。
把每个点转成区间,排序,首先考虑最左边的区间[l1,r1],要覆盖住这个点则需要在这个区间里的某个位置x放一个雷达,显然尽量放在靠右端是最好的,因为可以同时被右边的其他区间覆盖,但是要被右边的区间[l2,r2]覆盖还需满足l2<=x<=r2,所以要x=min(x,r2)更新x的值。
//#pragma comment(linker, "/STACK:1024000000,1024000000")#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;typedef long long ll;typedef unsigned long long ull;typedef pair pii;#define pb(a) push(a)#define INF 0x1f1f1f1f#define lson idx<<1,l,mid#define rson idx<<1|1,mid+1,r#define PI 3.1415926535898template T min(const T& a,const T& b,const T& c) { return min(min(a,b),min(a,c));}template T max(const T& a,const T& b,const T& c) { return max(max(a,b),max(a,c));}void debug() {#ifdef ONLINE_JUDGE#else freopen("in.txt","r",stdin); //freopen("d:\\out1.txt","w",stdout);#endif}int getch() { int ch; while((ch=getchar())!=EOF) { if(ch!=' '&&ch!='\n')return ch; } return EOF;}const int maxn = 10005;const double eps = 10e-8;typedef pair pdd;pdd da[maxn];double cal(int x,int y,int R){ if(abs(y)>R)return -1; return sqrt(R*R-y*y)+eps;}int main(){ int n,R; int ca=0; while(scanf("%d%d",&n,&R)!=EOF&&(n||R)) { int sol=1; for(int i=0;i
转载于:https://www.cnblogs.com/BMan/p/3650031.html