社区讨论

70分P3958 [NOIP2017 提高组] 奶酪

灌水区参与者 1已保存回复 0

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
0 条
当前快照
1 份
快照标识符
@m1uqbf91
此快照首次捕获于
2024/10/04 20:56
去年
此快照最后确认于
2025/11/04 18:03
4 个月前
查看原帖
1/2/4测试点Wa
感谢支持
CPP
#include<bits/stdc++.h>
using namespace std;
struct Bal//结构体:空洞
{
	int x,y,z;
	bool operator >(Bal a)
	{
		return z>a.z;
	}
	bool operator <(Bal a)
	{
		return z<a.z;
	}
	bool operator ==(Bal a)
	{
		return z==a.z;
	}
};
bool Tou(int x/*x上的距离*/,int y/*y上的距离*/,int z/*z上的距离*/,int d/*两倍半径*/)
  //判断能不能走过去
{
	double x1=double(x),y1=double(y),z1=double(z),d1=double(d);
	return sqrt(x1*x1+y1*y1+z1*z1)<=d1;
}
int main()
{
	int a;
	cin>>a;
	for(int A=0;A<a;A++)
	{
		int b,c,d;
		cin>>b>>c>>d;
		Bal Fil[b];
		for(int B=0;B<b;B++)
		{
			cin>>Fil[B].x>>Fil[B].y>>Fil[B].z;
		}
		sort(Fil,Fil+b);
		int e=0/*接触底的*/,f=b/*接触顶的*/;
		while(Fil[e].z<=d)
		{
			e++;
		}
		if(e==0)
		{
			cout<<"No"<<endl;
			continue;
		}
		while(Fil[f-1].z+d>=c)
		{
			f--;
		}
		if(f==b)
		{
			cout<<"No"<<endl;
			continue;
		}
		queue<int> Bfs;
		for(int B=0;B<e;B++)
		{
			Bfs.push(B);
		}
		bool Vis[b]={false};
		for(int B=0;B<e;B++)
		{
			Vis[B]=true;
		}
		bool Rea=false;
		while(!Bfs.empty())//开始Bfs
		{
			for(int B=0;B<b;B++)
			{
				if(Tou(Fil[B].x-Fil[Bfs.front()].x,Fil[B].y-Fil[Bfs.front()].y,Fil[B].z-Fil[Bfs.front()].z,2*d) && !Vis[B])
				{
					if(B>=f)
					{
						Rea=true;
						break;
					}
					Bfs.push(B);
					Vis[B]=true;
				}
			}
			if(Rea)
			{
				break;
			}
			Bfs.pop();
		}
		if(Rea)
		{
			cout<<"Yes"<<endl;
		}
		else
		{
			cout<<"No"<<endl;
		}
	}
}

回复

0 条回复,欢迎继续交流。

正在加载回复...