记录编号 |
585198 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[NOIP 2017]奶酪 |
最终得分 |
100 |
用户昵称 |
┭┮﹏┭┮ |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.266 s |
提交时间 |
2023-11-27 11:54:59 |
内存使用 |
3.46 MiB |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define P pair<int,int>
#define PP pair<int,P>
#define mp(x,y) make_pair(x,y)
const int N = 1e3+10,mod = 1e9+7;
ll t,n,h,r;
struct made{
ll x,y,z;
}a[N];
ll fa[N];
ll find(int x){
if(x == fa[x])return x;
return fa[x] = find(fa[x]);
}
void merge(int x,int y){
if(find(x) == find(y))return;
fa[find(x)] = find(y);
}
double dis(int i,int j){
return (double)sqrt((a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y)+(a[i].z-a[j].z)*(a[i].z-a[j].z));
}
int main(){
freopen("2017cheese.in","r",stdin);
freopen("2017cheese.out","w",stdout);
scanf("%lld",&t);
while(t--){
scanf("%lld%lld%lld",&n,&h,&r);
for(int i = 1;i <= n;i++)scanf("%lld%lld%lld",&a[i].x,&a[i].y,&a[i].z);
for(int i = 0;i <= n+1;i++)fa[i] = i;
for(int i = 1;i <= n;i++){
if(r >= a[i].z)merge(0,i);
for(int j = i+1;j <= n;j++){
if(dis(i,j) <= 2*r)merge(i,j);
}
if(r >= (h-a[i].z))merge(i,n+1);
}
if(find(0) == find(n+1))printf("Yes\n");
else printf("No\n");
}
return 0;
}