题解
2023-05-27 17:18:33
发布于:上海
8阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
struct Node{long long x,y,z;};
int main()
{
int t=0;
cin>>t;
for(int w=0;w<t;w++)
{
long long x[1009]={0};
long long y[1009]={0};
long long z[1009]={0};
int vst[1009]={0};
int tru=0;
int n=0,h=0,r=0;
cin>>n>>h>>r;
for(int i =1;i<=n;i++)
{
cin>>x[i]>>y[i]>>z[i];
}
queue<Node> q;
for(int i =1;i<=n;i++)
{
if(z[i]<=r)
{
vst[i]=1;
q.push((Node){x[i],y[i],z[i]});
//cout<<h-z[i]<<" "<<r<<endl;
if(h-z[i]<=r)
{
tru=1;
break;
}
}
}
while(!q.empty()&&tru==0)
{
Node now=q.front();
q.pop();
for(int i =1;i<=n;i++)
{
if(sqrt((x[i]-now.x)*(x[i]-now.x)+(y[i]-now.y)*(y[i]-now.y)+(z[i]-now.z)*(z[i]-now.z))<=r*2&&sqrt((x[i]-now.x)*(x[i]-now.x)+(y[i]-now.y)*(y[i]-now.y)+(z[i]-now.z)*(z[i]-now.z))!=0&&vst[i]==0)
{
q.push((Node){x[i],y[i],z[i]});
vst[i]=1;
//cout<<h-now.z<<" "<<r<<endl;
if(h-now.z<=r)
{
tru=1;
break;
}
}
}
}
for(int i =1;i<=n;i++)
{
if(h-z[i]<=r&&vst[i]==1)
{
tru=1;
break;
}
}
if(tru==0){
cout<<"No"<<endl;
}
else
{
cout<<"Yes"<<endl;
}
}
return 0;
}
这里空空如也
有帮助,赞一个