@[Sat233](/space/show?uid=260379) 使用Markdown吧
by Eason_AC2 @ 2019-11-02 10:36:56
这代码我看了也不想调
by __Hacheylight__ @ 2019-11-02 10:38:39
qwq
不换行太伤了
by Sat233 @ 2019-11-02 10:45:22
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
------------
using namespace std;
int s,p;
int x[510],y[510];
int fa[510];
struct data
{
int x,y;
double v;
}b[260000];
int num=0;
double dis(int i,int j
{
return sqrt( (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) );
}
bool cmp(data a,data b)
{
if(a.v<b.v)
return 1;
return 0;
}
int find(int a)
{
if(fa[a]==a)
return a;
fa[a]=find(fa[a]);
return fa[a]
;
}
double maxx(double x,double y)
{
if(x>y)
return x;
return y;
}
int main()
{
double ans=0;
cin>>s>>p;
for(int i=1;i<=p;++i)
cin>>x[i]>>y[i];
for(int i=1;i<=p;++i)
for(int j=i+1;j<=p;++j)
{
num++;
b[num].x=i;
b[num].y=j;
b[num].v=dis(i,j);
}
sort(b+1,b+num+1,cmp);
for(int i=1;i<=p;++i)
{
fa[i]=i;
}
s=p-s;
for(int i=1;i<=num,s>0;++i)
{
int fx=b[i].x,fy=b[i].y;
if(find(fx)!=find(fy))
{
fa[fx]=fy;s--;
ans=maxx(ans,b[i].v);
}
}
printf("%.2lf",ans);
return 0;
}
by Sat233 @ 2019-11-02 10:47:50
@[Sat233](/space/show?uid=260379) 按回复讨论下的一个插入代码,~~不然你换行伤,我们看也伤~~
by 爷,无限霸气 @ 2019-11-02 11:11:55
希更展,使MD
by robin_gao @ 2020-02-09 10:36:19