记录详情

Wrong Answer


  
# 状态 耗时 内存占用
#1 Accepted 1ms 348.0 KiB
#2 Accepted 1ms 992.0 KiB
#3 Wrong Answer 1ms 228.0 KiB
#4 Accepted 1ms 224.0 KiB
#5 Wrong Answer 7ms 228.0 KiB
#6 Wrong Answer 12ms 212.0 KiB
#7 Wrong Answer 21ms 216.0 KiB
#8 Wrong Answer 18ms 212.0 KiB
#9 Wrong Answer 19ms 212.0 KiB
#10 Wrong Answer 19ms 212.0 KiB

代码

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

inline int find(int x){
	return x==fa[x]?x:fa[x]=find(fa[x]);
}

bool cmp(b x,b y){
	return x.z>y.z;
}

inline void Init(){
	scanf("%d",&T);
}

inline void Work(){
	while(T--){
		scanf("%d%d%d",&n,&h,&r);
		for(int i=1;i<=n;i++){
			scanf("%lld%lld%lld",&bl[i].x,&bl[i].y,&bl[i].z);
		}
		memset(fa,0x3f,sizeof(fa));
		for(int i=1;i<=n;i++)fa[i]=i;
		fa[0]=0;fa[n+1]=n+1;
		sort(bl+1,bl+n+1,cmp);
		for(int i=1;i<=n;i++){
			if(h-bl[i].z<=r)fa[find(i)]=fa[0];
			if(bl[i].z<=r)fa[find(n+1)]=fa[find(i)];
			for(int j=i+1;bl[i].z-bl[j].z<=2*r&&j<=n;j++){
				if(bl[j].y-bl[i].y<=2*r&&bl[j].x-bl[j].x<=2*r)
					fa[find(j)]=fa[find(i)];
			}
		}
		if(fa[find(n+1)]==fa[find(0)])printf("Yes\n");
		else	printf("No\n");
	}
}
int main(){
	Init();
	Work();
	return 0;
}

信息

递交者
类型
递交
题目
P1012 奶酪
比赛
随机真题赛第二轮(xhy&lfy讲题)
题目数据
下载
语言
C++
递交时间
2019-11-12 07:41:03
评测时间
2019-11-12 07:41:04
评测机
分数
30
总耗时
105ms
峰值内存
992.0 KiB