https://www.luogu.com.cn/problem/P3958
#includeusing namespace std; const int N=1e3+9; typedef long long ll; int fa[N]; int find(int x){ if(fa[x]==x)return x; return fa[x]=find(fa[x]); } void merge(int a,int b){ fa[find(a)]=find(b); } struct node { ll a,b,c; }t[N]; ll dist(ll a,ll b,ll c,ll x,ll y,ll z){ return (a-x)*(a-x)+(b-y)*(b-y)+(c-z)*(c-z); } int main(){ int T; scanf("%d",&T); while(T--){ ll n,h,r; int arr1[N],arr2[N],cnt1=0,cnt2=0; scanf("%lld%lld%lld",&n,&h,&r); for(int i=1;i<=n;i++)fa[i]=i; for(int i=1;i<=n;i++){ ll a,b,c; scanf("%lld%lld%lld",&a,&b,&c); if(c+r>=h)arr2[++cnt2]=i; if(c-r<=0)arr1[++cnt1]=i; t[i]={a,b,c}; for(int j=1;j


![P3958 [NOIP2017 提高组] 奶酪 (并查集 连通性 P3958 [NOIP2017 提高组] 奶酪 (并查集 连通性](http://www.mshxw.com/aiimages/31/346653.png)
