记录详情

Wrong Answer


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

代码

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

int main()
{
  scanf("%d",&T);
  while(T--)
  {
  	for(int i=1;i<=n+2;i++) fa[i]=i;
  	scanf("%d %d %lld",&n,&h,&r);
  	for(int i=1;i<=n;i++)
  	{
  	  scanf("%lld %lld %lld",&x[i],&y[i],&z[i]);
  	  
	  if(z[i]<=r) 
	  {
	  	int r1=find(n+1),r2=find(i);
	  	if(r1!=r2)
		    fa[r1]=r2;
	  }
	  if(z[i]>=h-r)
	  {
	  	int r1=find(n+2),r2=find(i);
	  	if(r1!=r2)
		    fa[r1]=r2;
	  }
	  for(int 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))
  	    {
  	      int r1=find(i),r2=find(j);
		  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 12:53:29
评测时间
2019-11-12 12:53:29
评测机
分数
60
总耗时
143ms
峰值内存
332.0 KiB