社区讨论

萌妹求助 BZOJ AC 洛谷TLE 求大佬帮看看

P2619[国家集训队] Tree I参与者 11已保存回复 23

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
23 条
当前快照
1 份
快照标识符
@mi6zj0j7
此快照首次捕获于
2025/11/20 13:22
4 个月前
此快照最后确认于
2025/11/20 16:37
4 个月前
查看原帖
CPP
#include<bits/stdc++.h>
#define N 805
#define eps 1e-6
using namespace std;
int n,father[N],s,t;
double L;
struct Point
{
	double x,y;
}p[N];
inline int getfather(int x)
{
	if(father[x]==x)	return x;
	father[x]=getfather(father[x]);
	return father[x];
}
inline double dis(Point a,Point b)
{
	return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
inline bool check(double diameter)
{
	for(int i=1;i<=n+2;i++)	father[i]=i;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			int fx=getfather(i),fy=getfather(j);
			if(fx!=fy)
			{
				if(dis(i,j)>diameter)	continue;
				father[fx]=fy;		
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		
	}
	if(father[s]!=father[t])	return false;
	return true;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	cin>>n>>L;
	s=n+1; t=n+2;
	for(int i=1;i<=n;i++)	cin>>p[i].x>>p[i].y;
	double l=0,r=20000;
	while(l+eps<r)
	{
		double m=(l+r)/2;
		if(check(m))
	}
}

回复

23 条回复,欢迎继续交流。

正在加载回复...