The main idea of the topic: on a given plane n Point, to find a maximum point set, so that the distance between 22 does not exceed d
It's useless to go to death and add any pruning.
The randomization of Dafa is good
Random one sequence at a time, then greedy to join, then update the answer
It's said to be reliable? Anyway, it went straight through.
#include <bitset>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define Musing namespace STD;typedef bitset<M>Abcdstructpoint{intx, y;friendistream&operator>> (IStream &_,point &p) {return scanf("%d%d", &p.x,&p.y), _; }friend BOOL operator< (ConstPoint &p1,ConstPoint &p2) {returnp1.x < p2.x; }friend intDistance (ConstPoint &p1,ConstPoint &p2) {return(p1.x-p2.x) * (p1.x-p2.x) + (P1.Y-P2.Y) * (P1.Y-P2.Y); }}POINTS[M];intN,D;ABCD A[M];ABCD Now,able,ans;intMain () {intI,j;Cin>>n>>d; for(i=1; i<=n;i++)Cin>>points[i]; for(i=1; i<=n;i++) for(j=i+1; j<=n;j++)if(Distance (Points[i],points[j]) <=d*d) a[i][j]=a[j][i]=true;Static intORDER[M]; for(i=1; i<=n;i++) {able[i]=true; Order[i]=i; } for(j=1; j<= +; j + +) {ABCD able=::able; Now.reset (); for(i=1; i<=n;i++)if(Able[order[i]]) {now[order[i]]=true; able&=a[order[i]]; }if(Now.count () >ans.count ()) Ans=now; Random_shuffle (order+1, order+n+1); }cout<<ans.count () <<endl; for(i=1; i<=n;i++)if(Ans[i])printf("%d", i);return 0;}
Bzoj 4080 Wf2014 Sensor Network randomization