P3958 奶酪
一个爆搜就A了
CODE:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#define ll long long
using namespace std;
double dis(ll a1, ll a2, ll b1, ll b2, ll c1, ll c2){
return sqrt((a1-a2)*(a1-a2)+(b1-b2)*(b1-b2)+(c1-c2)*(c1-c2));
}
int T, n, flag, vis[1001];
ll h, r;
struct node{
ll x, y, z;
}e[1001];
void dfs(int x){
if(e[x].z+r>=h) flag=1;
if(flag)return;
vis[x]=1;
for(int i=1; i<=n; i++){
if(i==x)continue;
if(!vis[i]&&dis(e[x].x, e[i].x, e[x].y, e[i].y, e[x].z, e[i].z)<=2*r)dfs(i);
}
}
int main(){
scanf("%d", &T);
while(T--){
flag=0;
memset(vis, 0, sizeof(vis));
scanf("%d%lld%lld", &n, &h, &r);
for(int i=1; i<=n; i++)
scanf("%lld%lld%lld", &e[i].x, &e[i].y, &e[i].z);
for(int i=1; i<=n; i++){
if(e[i].z-r<=0) dfs(i);
if(flag){
printf("Yes\n");
break;
}
}
if(!flag)printf("No\n");
}
return 0;
}
不如吃茶去