社区讨论
关于奶酪这题,我死了求debug
P3958[NOIP 2017 提高组] 奶酪参与者 4已保存回复 12
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 12 条
- 当前快照
- 1 份
- 快照标识符
- @mi7cuqk7
- 此快照首次捕获于
- 2025/11/20 19:35 4 个月前
- 此快照最后确认于
- 2025/11/20 22:03 4 个月前
CPP
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;
const int N=100000+100;
const ll M=100000+10;
ll T,n,h,r;
bool judge;
double len;
ll root[N],top[N],bottom[N],cnt1,cnt2;
ll x[M],y[M],z[M];
ll find(int x)
{
int y=x;
while(y!=root[y])
{
y=root[y];
}
while(x!=root[x])
{
int ap=root[x];
root[x]=y;
x=ap;
}
return x;
}
double dist(int x,int y,int z,int x1,int y1,int z1)
{
return sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1)+(z-z1)*(z-z1));
}
int main()
{
cin>>T;
while(T--)
{
cnt1=0;cnt2=0;
cin>>n>>h>>r;
for(int i=1;i<=n;i++)
cin>>x[i]>>y[i]>>z[i];
for(int i=1;i<=n;i++) root[i]=i;
for(int i=1;i<=n;i++)
{
if((z[i]+r)>=h)
{
cnt1++;
top[cnt1]=i;
}
if((z[i]-r)<=0)
{
cnt2++;
bottom[cnt2]=i;
}
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
if(dist(x[i],y[i],z[i],x[j],y[j],z[j])<=2*r)
{
int fx=find(i);
int fy=find(j);
if(fx==fy) continue;
else
root[fx]=fy;
}
}
}
judge=false;
for(int i=1;i<=cnt2;i++)
{
for(int j=1;j<=cnt1;j++)
{
if(find(bottom[i])==find(top[j]))
{
judge=true;
break;
}
}
}
if(!judge)
cout<<"No"<<endl;
else
cout<<"Yes"<<endl;
}
return 0;
}
为什么dist传回来的数据会变成字符啊?
这组数据
1
2 5100500 1275250
0 0 1275250
0 50500 3825250
回复
共 12 条回复,欢迎继续交流。
正在加载回复...