记录详情

Accepted

自豪的采用 HydroJudge 进行评测(github.com/hydro-dev/HydroJudge)
{"receive":"2020-08-10T03:16:01.105Z","handle":"2020-08-10T03:16:01.105Z","cache_start":"2020-08-10T03:16:01.114Z","read_cases":"2020-08-10T03:16:01.290Z","judge":"2020-08-10T03:16:01.297Z","done":"2020-08-10T03:16:01.730Z"}
# 状态 耗时 内存占用
#1 Accepted 0ms 216.0 KiB
#2 Accepted 0ms 212.0 KiB
#3 Accepted 0ms 212.0 KiB
#4 Accepted 0ms 212.0 KiB
#5 Accepted 10ms 224.0 KiB
#6 Accepted 20ms 384.0 KiB
#7 Accepted 39ms 488.0 KiB
#8 Accepted 35ms 512.0 KiB
#9 Accepted 39ms 744.0 KiB
#10 Accepted 39ms 744.0 KiB

代码

#pragma GCC target("f16c")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector")
#pragma GCC optimize(3)
// luogu-judger-enable-o2
#include<cstdio>
struct Node{
    long long x,y,z;
}ho[1010];
long long n,h,r;
bool ans;
int f[1010],b1[1010],b2[1010];
inline long long read()
{
    long long x=0;int k=1;char c=getchar();
    while(c<'0')k^=(c=='-'),c=getchar();
    while(c>='0')x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return k?x:-x;
}
inline long long  dist(Node a,Node b)
{
    return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z);
}
inline int find(int x)
{
    return f[x]==x?x:f[x]=find(f[x]);
}
int main()
{
    register int x,y;
    register long long t=read();
    while(t--)
    {
     ans=false;
     n=read(),h=read(),r=read();
     for(register int i=1;i<=n;i++)
      f[i]=i,b1[i]=0,b2[i]=0;
     for(register int i=1;i<=n;i++)
      ho[i].x=read(),ho[i].y=read(),ho[i].z=read();
     for(register int i=1;i<=n;i++)
     {
      for(register int j=1;j<i;j++)
      {
       if(dist(ho[i],ho[j])<=2*r*2*r)
       {
         x=find(i),y=find(j);
         if(x!=y)
            f[x]=y;
       }
      }
     }
     for(register int i=1;i<=n;i++)
      if(ho[i].z>=h-r)
        b1[i]=1;
     for(register int i=1;i<=n;i++)
      if(ho[i].z<=r)
        b2[i]=1;
     for(register int i=1;i<=n;i++)
     for(register int j=1;j<=n;j++)
      if(b1[i]&&b2[j]&&find(f[i])==find(f[j]))
      {
	   ans=true;
       break;
	  }   
     puts(ans?"Yes":"No");  
    }
    return 0;
}

信息

递交者
类型
递交
题目
P1012 奶酪
题目数据
下载
语言
C++
递交时间
2019-11-12 09:20:12
评测时间
2020-08-10 11:16:01
评测机
分数
100
总耗时
187ms
峰值内存
744.0 KiB