80Pts求助(玄关)
查看原帖
80Pts求助(玄关)
924576
huangzirui2012楼主2024/10/22 23:21

8AC,2WA8AC,2WA

$$
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll t,n,h,r,p,dis[1005];
struct node{
	ll x,y,z;
}a[1005];
ll dist(node p1,node p2){
	return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)+(p1.z-p2.z)*(p1.z-p2.z));
}
inline ll read(){
	char c=getchar();
	ll s=0,st=1;
	while (c<'0'||c>'9') {
		if (c=='-') st=-1;
		c=getchar();
	}
	while (c>='0'&&c<='9') {
		s=(s<<3)+(s<<1)+c-'0';
		c=getchar();
	}
	return s*st;
} 
int main(){
	t=read();
	while(t--){
		p=0;
		memset(dis,0,sizeof(dis));
		queue<ll> q;
		n=read();
		h=read();
		r=read();
		for(int i=1;i<=n;i++){
			a[i].x=read();
			a[i].y=read();
			a[i].z=read();
			if(a[i].z-r<=0){
				q.push(i);
				dis[i]=1;
			}
		}
		while(!q.empty()){
			ll x=q.front();
			q.pop();
			if(a[x].z+r>=h){
				cout<<"Yes";
				p=1;
				break;
			}
			for(int i=1;i<=n;i++){
				if(dis[i]){
					continue ;
				}
				if(i!=x){
					if(2*r>=dist(a[x],a[i])&&a[i].z>=a[x].z){
						q.push(i);
						dis[i]=1;
					}
				}
			}
		}
		if(!p){
			cout<<"No";
		}
		cout<<endl;
	}
	
	return 0;
}
2024/10/22 23:21
加载中...