#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#include<bits/stdc++.h>
#define For(i,l,r) for(int i=l,i##end=r;i<=i##end;i++)
#define rFor(i,r,l) for(int i=r,i##end=l;i>=i##end;i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
inline void wrt(int x,const char endc=10) {
static char buf[21],*nw;nw=buf;
if(!x){putchar(48);goto end;}
if(x<0)putchar(45),x=-x;
while(x)*(nw++)=x%10+48,x/=10;
while(nw!=buf)putchar(*(--nw));
end:putchar(endc);
}
inline int _isdigit(const char x){return x>47 and x<58;}
inline int rd() {
static int f,x;
static char c;
f=x=0;
do if((c=getchar())==45)f=1;while(!_isdigit(c));
do x=(x<<1)+(x<<3)+c-48;while(_isdigit(c=getchar()));
return f?-x:x;
}
int n,f[1010];
int fd(const int x){return f[x]==x?x:f[x]=fd(f[x]);}
inline ll sqr(const ll x){return x*x;}
void mg(const int a,const int b){f[fd(a)]=fd(b);}
void work()
{
static ll x[1010],y[1010],z[1010],h,r;
static int n;
n=rd(),h=rd(),r=rd();
For(i,0,n+1)f[i]=i;
For(i,1,n) {
x[i]=rd(),y[i]=rd(),z[i]=rd();
if(z[i]<=r)mg(0,i);
if(r+z[i]>=h)mg(i,n+1);
}
For(i,1,n)
For(j,i+1,n)
if(sqr(x[i]-x[j])+sqr(y[i]-y[j])+sqr(z[i]-z[j])<=r*r<<2)
mg(i,j);
static const string anss[]={"No","Yes"};
puts(anss[fd(0)==fd(n+1)].c_str());
}
int main() {
For(i,1,rd())work();
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 38.25 us | 52 KB | Accepted | Score: 10 | 显示更多 |
Testcase #2 | 46.8 us | 52 KB | Accepted | Score: 10 | 显示更多 |
Testcase #3 | 46.12 us | 52 KB | Accepted | Score: 10 | 显示更多 |
Testcase #4 | 63.09 us | 52 KB | Accepted | Score: 10 | 显示更多 |
Testcase #5 | 3.038 ms | 72 KB | Accepted | Score: 10 | 显示更多 |
Testcase #6 | 6.059 ms | 68 KB | Accepted | Score: 10 | 显示更多 |
Testcase #7 | 11.897 ms | 72 KB | Accepted | Score: 10 | 显示更多 |
Testcase #8 | 10.698 ms | 68 KB | Accepted | Score: 10 | 显示更多 |
Testcase #9 | 11.625 ms | 68 KB | Accepted | Score: 10 | 显示更多 |
Testcase #10 | 11.73 ms | 64 KB | Accepted | Score: 10 | 显示更多 |