HDU 2295 Radar Repeat overlay + two points

Source: Internet
Author: User
Tags radar

Topic links

For M radar, N cities, and the coordinates of each city, the M radar can only use K, and the minimum radius is obtained under the condition that the K radar surrounds all cities.

First to find out the distance of each radar to all cities, and then the two-radius, if the distance is less than two points, add the edge (probably not called add edge, I do not know what to call ...)

#include <bits/stdc++.h>using namespacestd;#definePB (x) push_back (x)#definell Long Long#defineMK (x, y) make_pair (x, y)#defineLson L, M, rt<<1#defineMem (a) memset (a, 0, sizeof (a))#defineRson m+1, R, rt<<1|1#defineMem1 (a) memset (a,-1, sizeof (a))#defineMEM2 (a) memset (a, 0x3f, sizeof (a))#defineRep (I, A, n) for (int i = A; i<n; i++)#defineull unsigned long Longtypedef pair<int,int>PLL;Const DoublePI = ACOs (-1.0);Const DoubleEPS = 1e-8;Const intMoD = 1e9+7;Const intINF =1061109567;Const intdir[][2] = { {-1,0}, {1,0}, {0, -1}, {0,1} };Const intMAXN =305;Const intMaxnode = the;structnode{intx, y;} a[Wuyi], b[Wuyi];structDLX {intL[maxnode], R[maxnode], U[maxnode], D[maxnode], Row[maxnode], Col[maxnode]; intS[MAXN], H[MAXN], deep, ans[maxn], SZ, N, M, K; Doubleg[ the][ the]; voidRemoveintc) { for(inti = d[c]; I!=c; i =D[i]) {L[r[i]]=L[i]; R[l[i]]=R[i]; }    }    voidResumeintc) { for(inti = u[c]; I!=c; i =U[i]) {L[r[i]]=i; R[l[i]]=i; }    }    inth () {intCNT =0; intvis[ the];        Mem (VIS);  for(inti = r[0]; i!=0; i =R[i]) {            if(!Vis[i]) {CNT++; Vis[i]=1;  for(intj = D[i]; J!=i; j =D[j]) {                     for(intk = R[j]; K!=j; K =R[k]) {Vis[col[k]]=1; }                }            }        }        returnCNT; }    intDfsintd) {if(D+h () >k)return 0; if(r[0] ==0) {            return 1; }        intc = r[0];  for(inti = r[0]; i!=0; i =R[i])if(s[c]>s[i]) C=i;  for(inti = d[c]; I!=c; i =D[i])            {Remove (i);  for(intj = R[i]; J!=i; j =R[j]) Remove (j); if(Dfs (d+1))                return 1;  for(intj = L[i]; J!=i; j =L[j]) resume (j);        Resume (i); }        return 0; }    voidAddintRintc) {sz++; ROW[SZ]=R; COL[SZ]=C; S[C]++; U[SZ]=U[c]; D[SZ]=C; D[U[C]]=sz; U[C]=sz; if(~H[r]) {R[sz]=H[r]; L[SZ]=L[h[r]]; L[R[SZ]]=sz; R[L[SZ]]=sz; } Else{H[r]= L[sz] = R[sz] =sz; }    }    voidinit () {mem1 (H);  for(inti =0; i<=n; i++) {R[i]= i+1; L[i]= I1; U[i]=i; D[i]=i;        } mem (S); R[n]=0; l[0] =N; SZ=N; }    DoubleDisintIintj) {returnsqrt1.0* (b[i].x-a[j].x) * (b[i].x-a[j].x) + (B[I].Y-A[J].Y) * (b[i].y-a[j].y)); }    intCheckDoublemid) {init ();  for(inti =1; i<=m; i++) {             for(intj =1; j<=n; J + +) {                if(mid-g[i][j]>=EPS)                {Add (I, j); }            }        }        if(Dfs (0))            return 1; return 0; }    voidsolve () {mem (g);  for(inti =1; i<=n; i++) scanf ("%d%d", &a[i].x, &a[i].y);  for(inti =1; i<=m; i++) scanf ("%d%d", &b[i].x, &b[i].y);  for(inti =1; i<=m; i++) {             for(intj =1; j<=n; J + +) {G[i][j]=Dis (i, j); }        }        DoubleL =0, r = the;  while(r-l>EPS) {            DoubleMid = (l+r)/2; if(check (mid)) R=mid; ElseL=mid; } printf ("%.6f\n", L); }}DLX;intMain () {intT; CIN>>T;  while(t--) {scanf ("%d%d%d", &AMP;DLX.N, &AMP;DLX.M, &DLX.K);    Dlx.solve (); }    return 0;}

HDU 2295 Radar Repeat overlay + two points

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.