Bzoj 4080 Wf2014 Sensor Network randomization

Source: Internet
Author: User
Tags bitset

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

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.