为什么你们都不用二分啊

P1991 无线通讯网

@[lc_lca](/user/120340)
by 忘怀星 @ 2020-05-10 23:59:57


等会,查bug @[忘怀星](/user/305911)
by lc_lca @ 2020-05-11 00:00:41


@[忘怀星](/user/305911) 您是二分吗
by lc_lca @ 2020-05-11 00:03:19


@[lc_lca](/user/120340) 不是,但是我大概知道二分做法
by 忘怀星 @ 2020-05-11 00:03:59


您的主页真好,树形DP题单,顺走了
by 忘怀星 @ 2020-05-11 00:04:39


我很想知道我错在哪里了qwq @[忘怀星](/user/305911)
by lc_lca @ 2020-05-11 00:05:28


qwq
by 忘怀星 @ 2020-05-11 00:06:28


```cpp #include<iostream> #include<algorithm> #include<math.h> using namespace std; int s,p; double x[510],y[510]; int f[510]; int findx(int x) { if(x==f[x]) return x; return f[x]=findx(f[x]); } void init() { for(int i=1;i<=500;i++) f[i]=i; } int main() { cin>>s>>p; for(int i=1;i<=p;i++) { cin>>x[i]>>y[i]; } double l=0,r=100000000; double ans=0; while(l<=r) { double mid=(l+r)/2; //cout<<mid<<endl; init(); for(int i=1;i<=p;i++) { //double xx=x[i],yy=y[i]; for(int j=1;j<=p;j++) { if(j==i) continue; if(double(x[i]-x[j])*(x[i]-x[j])<=mid && double(y[i]-y[j])*(y[i]-y[j])<=mid) { int fx=findx(i); int fy=findx(j); if(fx!=fy) f[fx]=fy; } } } int sum=0; for(int i=1;i<=p;i++) { if(f[i]==i) sum++; } if(sum<=s) { ans=mid; r=mid-1; } else l=mid+1; } printf("%.2f\n",(double)sqrt((double)ans)); return 0; } ```
by lc_lca @ 2020-05-11 00:06:28


wozhidaol
by lc_lca @ 2020-05-11 00:08:27


您这个……二分了个啥?
by 忘怀星 @ 2020-05-11 00:08:43


上一页 | 下一页