我的并查集你自己看一下
```cpp
#include<iostream>
#include<cstdio>
#include<cmath>
#define ll long long
using namespace std;
ll f[1000001],f2[10000001],f1[10000001];
ll finda(ll x)
{
if(f[x]!=x)
f[x]=finda(f[x]);
return f[x];
}
struct place
{
ll x,y,z;
} a[10000001];
int main()
{
ll t;
cin>>t;
while(t--)
{
ll n,h,r;
cin>>n>>h>>r;
ll up=0,down=0;
for(ll i=1; i<=n; i++)
f[i]=i;
for(ll i=1; i<=n; i++)
{
cin>>a[i].x>>a[i].y>>a[i].z;
if(a[i].z+r>=h)
up++,f1[up]=i;
if(a[i].z-r<=0)
down++,f2[down]=i;
for (ll j=1; j<=i; j++)
{
if (sqrt((a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y)+(a[i].z-a[j].z)*(a[i].z-a[j].z))<=2*r)
{
ll a1=finda(i);
ll a2=finda(j);
if (a1!=a2)
f[a1]=a2;
}
}
}
ll judge=0;
for (ll i=1; i<=up; i++)
{
for (ll j=1; j<=down; j++)
if (finda(f1[i])==finda(f2[j]))
judge=1;
if (judge==1)
break;
}
if (judge==1)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
return 0;
}
```
by Mr_浓氨 @ 2018-10-14 11:37:55
@[浓氨with氢氟酸](/space/show?uid=38427)
我把距离改为double之后就变80分了,但为什么前两组会re啊?
by maxmascle @ 2018-10-14 11:43:01
@[浓氨with氢氟酸](/space/show?uid=38427)
是因为得开long long吗?
by maxmascle @ 2018-10-14 11:44:09
long long
by Patrickpwq @ 2018-10-14 12:17:13
@[Patrickpwq](/space/show?uid=60299) 改了long long前两组还是re啊怎么办?
by maxmascle @ 2018-10-14 12:38:52
@[maxmascle](/space/show?uid=55975) 数组小了
by Patrickpwq @ 2018-10-14 15:01:00
@[maxmascle](/space/show?uid=55975) 数组小了
by Mr_浓氨 @ 2018-10-14 16:16:37
@[maxmascle](/space/show?uid=55975)
你看我开了多大,你开了多大
by Mr_浓氨 @ 2018-10-14 16:16:57
@[浓氨with氢氟酸](/space/show?uid=38427)
哦哦,谢谢
by maxmascle @ 2018-10-16 14:31:13
@[Patrickpwq](/space/show?uid=60299) 谢谢
by maxmascle @ 2018-10-16 14:31:32