rt,WA on #5 #6 #7。dis已经开了ull仍WA。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e3+5;
ll n,h,r,x[N],y[N],z[N],fa[N];
set<int> buttom,top;
ll gf(int x){
if(fa[x]==x) return x;
return fa[x]=gf(fa[x]);
}
ull dis(ll xa,ll ya,ll za,ll xb,ll yb,ll zb){
return ceil(sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb)+(za-zb)*(za-zb)));
}
void solve(){
buttom.clear();
top.clear();
memset(x,0,sizeof(x));
memset(y,0,sizeof(y));
memset(z,0,sizeof(z));
cin>>n>>h>>r;
for(int i=1;i<=n;i++) cin>>x[i]>>y[i]>>z[i];
for(int i=1;i<=n;i++) fa[i]=i;
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++){
if(dis(x[i],y[i],z[i],x[j],y[j],z[j])<=2*r){
ll fx=gf(i),fy=gf(j);
fa[fx]=fy;
}
}
}
for(int i=1;i<=n;i++){
if(z[i]-r<=0) buttom.insert(fa[i]);
if(z[i]+r>=h) top.insert(fa[i]);
if(buttom.count(fa[i])&&top.count(fa[i])){
cout<<"Yes"<<endl;
return;
}
}
cout<<"No"<<endl;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int T;
cin>>T;
while(T--){
solve();
}
return 0;
}