#include<bits/stdc++.h>
using namespace std;
#define R(x) x=rd()
char buf[1<<23],*p1=buf,*p2=buf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
inline int rd() {
int x=0,f=1;char ch=getchar();
while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
while(isdigit(ch)) x=x*10+(ch^48),ch=getchar();
return x*f;
}
char pbuf[1<<20], *pp=pbuf;
inline void push(const char &c){if(pp - pbuf == 1<<20)fwrite(pbuf, 1, 1<<20, stdout),pp = pbuf;*pp++ = c;}
class io{public:~io(){fwrite(pbuf, 1, pp - pbuf, stdout);}}_;
inline void write(int x) {
if (x<0)x=-x,push('-');
int sta[35],top=0;
do{sta[top++]=x%10,x/=10;}while (x);
while(top)push(sta[--top]^'0');
}
int t;
int n,h,r;
int x[1001],y[1001],z[1001];
int a[1001];
int s[1001],e[1001];
int ls,le;
int find(int x){
if(x==a[x]){
return x;
}else{
return (a[x]=find(a[x]));
}
}
double l(int x1,int y1,int z1,int x2,int y2,int z2){
return sqrt( pow(x2-x1,2) + pow(y2-y1,2) + pow(z2-z1,2) );
}
void run(){
for(int i=1;i<=ls;i++){
for(int j=1;j<=le;j++){
if(find(s[i])==find(e[j])){
push('Y');
push('e');
push('s');
push('\n');
return;
}
}
}
push('N');
push('o');
push('\n');
return;
}
signed main(){
R(t);
while(t--){
ls=le=0;
// cin >> n >> h >> r;
R(n);
R(h);
R(r);
for(int i=1;i<=n;i++)a[i]=i;
for(int i=1;i<=n;i++){
// cin >> x[i] >> y[i] >> z[i];
R(x[i]);
R(y[i]);
R(z[i]);
if(z[i]+r>=h)e[++le]=i;//这个空洞能上去
if(z[i]-r<=0)s[++ls]=i;//可以作为出发点
for(int j=1;j<i;j++){
if(l(x[i],y[i],z[i],x[j],y[j],z[j]) <= 2*r){
a[find(i)]=find(j);
}
}
}
// for(int i=1;i<=n;i++)cout << a[i] << " ";
run();
}
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 41.04 us | 68 KB | Accepted | Score: 10 | 显示更多 |
Testcase #2 | 36.53 us | 68 KB | Accepted | Score: 10 | 显示更多 |
Testcase #3 | 36.48 us | 68 KB | Accepted | Score: 10 | 显示更多 |
Testcase #4 | 47.55 us | 68 KB | Accepted | Score: 10 | 显示更多 |
Testcase #5 | 8.864 ms | 144 KB | Accepted | Score: 10 | 显示更多 |
Testcase #6 | 17.704 ms | 220 KB | Accepted | Score: 10 | 显示更多 |
Testcase #7 | 35.256 ms | 372 KB | Accepted | Score: 10 | 显示更多 |
Testcase #8 | 31.676 ms | 340 KB | Accepted | Score: 10 | 显示更多 |
Testcase #9 | 33.543 ms | 580 KB | Accepted | Score: 10 | 显示更多 |
Testcase #10 | 33.589 ms | 580 KB | Accepted | Score: 10 | 显示更多 |