NOIP 2016 奶酪

这么水的题才拿了80分????????????????

QAQ AWSL

sqrt精度问题要注意,最好不开方而去比较平方避免精度问题

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring> 
#include<cmath>
using namespace std;
struct pp{
    long long x;
    long long y;
    long long z;
    long long v;
    
}e[60002];
long long t,n,m,res,ans,cnt,num,h,r,u1,d1;
int up[60002],down[60002],vis[60002];
long long dis(pp x,pp y ){
    return (x.x-y.x)*(x.x-y.x)+(x.y-y.y)*(x.y-y.y)+(x.z-y.z)*(x.z-y.z);
}
bool jud(pp x,pp y){
    if(dis(x,y)<=(r*2)*(r*2)) return 1;
    return 0;
}
bool dfs(pp x){
    vis[x.v]=1;
    if(up[x.v]) {
        return 1;
    }
    for(int i=1;i<=n;i++){
        if(vis[e[i].v]) continue;
        if(jud(x,e[i])){
            if(dfs(e[i]))
            return 1;
        }
    }
    return 0;
}
int main(){
    scanf("%lld",&t);
    while(t--){
        scanf("%lld%lld%lld",&n,&h,&r);
        ans=0;
        d1=0;
        memset(vis,0,sizeof(vis));
        memset(up,0,sizeof(up));
        for(int i=1;i<=n;i++){
            scanf("%lld%lld%lld",&e[i].x,&e[i].y,&e[i].z);
            e[i].v=i;
            if(e[i].z+r>=h) up[i]=1;
            if(e[i].z-r<=0) down[++d1]=i;
        }
        for(int i=1;i<=d1;i++){
            if(vis[e[down[i]].v]) continue;
            if(dfs(e[down[i]])){
                ans=1;
                break;
            }
        }
        if(ans==1) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}
奶酪

 

posted @ 2019-10-02 09:27  _loverr  阅读(178)  评论(0编辑  收藏  举报
Live2D