#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1005;
ll fa[N],n,h,r,x[N],y[N],z[N];
ll find(ll x) {
if (x!=fa[x]) fa[x]=find(fa[x]);
return fa[x];
}
void comb(ll x,ll y) {
x=find(x),y=find(y);
if (x==y) return;
fa[x]=y;
}
bool dis(ll x,ll y,ll z,ll r) {
long double t=sqrt(x*x+y*y+z*z);
return t<=(long double)2*r;
}
int main() {
ll T; scanf("%lld",&T);
while (T--) {
scanf("%lld%lld%lld",&n,&h,&r);
for (ll i=1; i<=n; i++) scanf("%lld%lld%lld",&x[i],&y[i],&z[i]);
for (ll i=1; i<=n; i++) fa[i]=i;
for (ll i=1; i<=n; i++)
for (ll j=i+1; j<=n; j++) {
if (dis(x[i]-x[j],y[i]-y[j],z[i]-z[j],r))
comb(i,j);
// printf("!!! %d %d %lld %lld %lld\n",i,j,x[i]-x[j],y[i]-y[j],z[i]-z[j]);
}
bool flag=false;
for (ll i=1; i<=n; i++) {
for (ll j=i; j<=n; j++)
if (z[i]<=r && z[j]>=h-r && find(i)==find(j)) {
flag=true; break;
}
if (flag) break;
}
if (flag) printf("Yes\n");
else printf("No\n");
}
return 0;
}
/*
3
2 4 1
0 0 1
0 0 3
2 5 1
0 0 1
0 0 4
2 5 2
0 0 2
2 0 4
(unsigned long long)
*/
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 38.01 us | 52 KB | Accepted | Score: 10 | 显示更多 |
| Testcase #2 | 51.02 us | 52 KB | Accepted | Score: 10 | 显示更多 |
| Testcase #3 | 48.42 us | 52 KB | Accepted | Score: 10 | 显示更多 |
| Testcase #4 | 63.12 us | 52 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #5 | 8.137 ms | 68 KB | Accepted | Score: 10 | 显示更多 |
| Testcase #6 | 15.822 ms | 68 KB | Accepted | Score: 10 | 显示更多 |
| Testcase #7 | 33.489 ms | 68 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #8 | 29.53 ms | 68 KB | Accepted | Score: 10 | 显示更多 |
| Testcase #9 | 32.533 ms | 68 KB | Accepted | Score: 10 | 显示更多 |
| Testcase #10 | 32.09 ms | 68 KB | Accepted | Score: 10 | 显示更多 |