30pts求调qwq
查看原帖
30pts求调qwq
547238
篮网总冠军楼主2024/10/3 20:52

#include <bits/stdc++.h>
using namespace std;

struct node{
	int x,y,z;
}a[1005];
int n,h,r;
bool dis(node x,node y){
	long long rt=(x.x-y.x)*(x.x-y.x)+(x.y-y.y)*(x.y-y.y)+(x.z-y.z)*(x.z-y.z);
	if (2*r>=sqrt(rt)) return true;
	else return false;
}
bool cmp(node x,node y){
	if (x.z!=y.z) return x.z<y.z;
	if (x.y!=y.y) return x.y<y.y;
	return x.x<y.x;
}
bool f;
bool vis[1005];
void dfs(int w){
	if(f) return;
	if (a[w].z+r>=h){
		f=1;
		return;
	}
	vis[w]=1;
	for(int i=1;i<=n;i++){
		if (vis[i]) continue;
		if (dis(a[w],a[i])) dfs(i);
	}
}
bool pd(int w){
	if (a[w].z-r>0) return false;
	return true;
}
int main(){
//	freopen("P3958_3.in","r",stdin);
//	freopen(".out","w",stdout);
	int t;
	cin>>t;
	while(t--){
		memset(vis,0,sizeof(vis));
		cin>>n>>h>>r;
		for(int i=1;i<=n;i++) cin>>a[i].x>>a[i].y>>a[i].z;
		f=0;
		sort(a+1,a+1+n,cmp);
		if (pd(1)) dfs(1);
		if (f) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}
2024/10/3 20:52
加载中...