#include<bits/stdc++.h>
using namespace std;
int t;
struct Hole{
double x,y,z;
}ho[1010];
inline double dist(int a,int b){
double xx=ho[a].x-ho[b].x,yy=ho[a].y-ho[b].y,zz=ho[a].z-ho[b].z;
return sqrt(xx*xx+yy*yy+zz*zz);
}
int n,h,r,start[1010],cnt;
bool vis[1010],ed[1010],flag;
void dfs(int u){
if(flag)return;
if(ed[u]){
flag=1;
return;
}
for(int i=1;i<=n;i++){
if(vis[i]||dist(u,i)>(double)(r*2))continue;
vis[i]=1;
dfs(i);
}
return;
}
int main(){
scanf("%d",&t);
while(t--){
cnt=0;
flag=0;
memset(vis,0,sizeof(vis));
memset(ed,0,sizeof(ed));
scanf("%d%d%d",&n,&h,&r);
for(int i=1;i<=n;i++){
scanf("%lf%lf%lf",&ho[i].x,&ho[i].y,&ho[i].z);
if(ho[i].z-r<=0)start[++cnt]=i;
if(ho[i].z+r>=h)ed[i]=1;
}
for(int i=1;i<=cnt;i++)
if(!flag){
vis[start[i]]=1;dfs(start[i]);
}
if(flag)puts("Yes");
else puts("No");
}
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 37.76 us | 52 KB | Accepted | Score: 10 | 显示更多 |
Testcase #2 | 51.81 us | 52 KB | Accepted | Score: 10 | 显示更多 |
Testcase #3 | 47.44 us | 52 KB | Accepted | Score: 10 | 显示更多 |
Testcase #4 | 75.71 us | 52 KB | Accepted | Score: 10 | 显示更多 |
Testcase #5 | 1.062 ms | 72 KB | Accepted | Score: 10 | 显示更多 |
Testcase #6 | 6.281 ms | 72 KB | Accepted | Score: 10 | 显示更多 |
Testcase #7 | 5.978 ms | 72 KB | Accepted | Score: 10 | 显示更多 |
Testcase #8 | 13.181 ms | 72 KB | Accepted | Score: 10 | 显示更多 |
Testcase #9 | 5.467 ms | 72 KB | Accepted | Score: 10 | 显示更多 |
Testcase #10 | 11.6 ms | 72 KB | Accepted | Score: 10 | 显示更多 |