记录详情

Wrong Answer


  
# 状态 耗时 内存占用
#1 Accepted 1ms 320.0 KiB
#2 Accepted 1ms 208.0 KiB
#3 Wrong Answer 1ms 204.0 KiB
#4 Accepted 1ms 212.0 KiB
#5 Wrong Answer 8ms 328.0 KiB
#6 Accepted 15ms 212.0 KiB
#7 Accepted 29ms 320.0 KiB
#8 Accepted 26ms 328.0 KiB
#9 Wrong Answer 30ms 324.0 KiB
#10 Wrong Answer 30ms 332.0 KiB

代码

#include<bits/stdc++.h>
using namespace std;
const long long maxn=1010;
long long T,n,h;
long long fa[maxn];
long long x[maxn],y[maxn],z[maxn],r;
long long find(long long x)
{
  if(fa[x]==x) return x;
  return fa[x]=find(fa[x]);
}

int main()
{
  scanf("%lld",&T);
  while(T--)
  {
  	for(long long i=1;i<=n+2;i++) fa[i]=i;
  	scanf("%lld %lld %lld",&n,&h,&r);
  	for(long long i=1;i<=n;i++)
  	{
  	  scanf("%lld %lld %lld",&x[i],&y[i],&z[i]);
  	  for(long long j=1;j<i;j++)
  	    if((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j])<=(r*r*4ll))
  	    {
  	      long long r1=find(i),r2=find(j);
		  if(r1!=r2)
		    fa[r1]=r2;	
		}
	  if(z[i]<=r) 
	  {
	  	long long r1=find(n+1),r2=find(i);
	  	if(r1!=r2)
		    fa[r1]=r2;
	  }
	  if(z[i]>=h-r)
	  {
	  	long long r1=find(n+2),r2=find(i);
	  	if(r1!=r2)
		    fa[r1]=r2;
	  }
	}
	if(find(n+1)==find(n+2)) printf("Yes\n");
	else printf("No\n");
  }
  return 0;
}

信息

递交者
类型
递交
题目
P1012 奶酪
题目数据
下载
语言
C++
递交时间
2019-11-12 09:18:20
评测时间
2019-11-13 15:59:28
评测机
分数
60
总耗时
146ms
峰值内存
332.0 KiB