当前位置:网站首页>Dojnoip201708 cheese solution
Dojnoip201708 cheese solution
2022-07-28 13:49:00 【bj_ hacker】
DOJNOIP201708 Cheese solution
subject
link
https://deeplearning.org.cn/problem/CCF-1147
Literal description
describe
There's a big piece of cheese , Its height is h, Its length and width can be considered infinite , There are many spherical cavities with the same radius in the middle of the cheese . We can set up a space coordinate system in this cheese , In the coordinate system , The bottom surface of the cheese is z = 0, The top surface of the cheese is z = h. Now? , There is a little mouse on the bottom of the cheese Jerry, It knows the coordinates of all the hollow centers in the cheese . If two cavities are tangent or intersect , be Jerry You can run from one hole to another , Specially , If a cavity is tangent to or intersects the lower surface ,Jerry You can run from the bottom of the cheese into the void ; If A void is tangent to or intersects the upper surface ,Jerry You can go from the void to the top of the cheese . On the lower surface of cheese Jerry Want to know , Without destroying the cheese , Can you use the existing cavity to run to the upper surface of the cheese ? Two points in space P1(x1,y1,z1)、P2(x2,y2,z2) The formula of distance is as follows :
dist(P1,P2)=sqrt((x1−x2)2+(y1−y2)2+(z1−z2)2)
This is the explanation of the following example :
Input description
Enter the file name as cheese.in. Each input file contains multiple sets of data . The first line of the input file , Contains a positive integer T, Represents the number of data groups contained in the input file . Next is T Group data , The format of each group of data is as follows : The first line contains three positive integers n,h and r, The two numbers are separated by a space , They stand for cheese The number of holes , The height of the cheese and the radius of the void . Next n That's ok , Each line contains three integers x、y、z, The two numbers are separated by a space , Said empty The coordinates of the center of the hole are (x,y,z).
Output description
The output file name is cheese.out. The output file contains T That's ok , They correspond to each other T The answer to group data , If in the first place i In group data ,Jerry You can do it from below The surface runs to the upper surface , The output “Yes”, If not , The output “No” ( No quotation marks ).
Use case input 1
3
2 4 1
0 0 1
0 0 3
2 5 1
0 0 1
0 0 4
2 5 2
0 0 2
2 0 4
Use case output 1
Yes
No
Yes
Tips
Sample explanation :
about 20% The data of ,n = 1,1 ≤ h , r ≤ 10,000, The absolute value of the coordinates does not exceed 10,000.
about 40% The data of ,1 ≤ n ≤ 8, 1 ≤ h , r ≤ 10,000, The absolute value of the coordinates does not exceed 10,000.
about 80% The data of , 1 ≤ n ≤ 1,000, 1 ≤ h , r ≤ 10,000, The absolute value of the coordinates does not exceed 10,000.
about 100% The data of ,1 ≤ n ≤ 1,000,1 ≤ h , r ≤ 1,000,000,000,T ≤ 20, The absolute value of the coordinates does not exceed 1,000,000,000.
Code implementation
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=1e3+10;
int t,n,h,r;
int fa[maxn],x[maxn],y[maxn],z[maxn],a[maxn],b[maxn];
inline int find(int x){
if(x==fa[x])return x;
return fa[x]=find(fa[x]);
}
inline void union_(int x,int y){
int fx1=find(x);
int fy1=find(y);
if(fx1==fy1)return;
else fa[fx1]=fy1;
}
inline double dis(int x1,int y1,int z1,int x2,int y2,int z2){
return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2));
}
signed main(){
scanf("%d",&t);
while(t--){
int cnt1=0,cnt2=0;
scanf("%d%d%d",&n,&h,&r);
for(int i=1;i<=n;i++){
fa[i]=i;
scanf("%d%d%d",&x[i],&y[i],&z[i]);
if(z[i]-r<=0)a[++cnt1]=i;
if(z[i]+r>=h)b[++cnt2]=i;
for(int j=1;j<=i;j++){
if(dis(x[i],y[i],z[i],x[j],y[j],z[j])<=2*r)union_(i,j);
}
}
bool flag=false;
for(int i=1;i<=cnt1;i++){
for(int j=1;j<=cnt2;j++){
if(find(a[i])==find(b[j])){
flag=true;
break;
}
}
if(flag==true)break;
}
if(flag)printf("Yes\n");
else printf("No\n");
}
return 0;
}
边栏推荐
- C language: quick sorting of sequential storage structure
- 7.依赖注入
- Beyond Istio OSS——Istio服务网格的现状与未来
- Customized template in wechat applet
- 【安全】 阅读 RFC6749 及理解 Oauth2.0 下的授权码模式
- Rust 从入门到精通01-简介
- 国产API管理工具Eolink太好用了,打造高效的研发利器
- Rust from introduction to mastery 01 introduction
- 【架构】评分较高的三本微服务书籍的阅读笔记
- DXF读写:对齐尺寸标注文字居中、上方的位置计算
猜你喜欢

在 Kubernetes 中部署应用交付服务(第 1 部分)

The domestic API management tool eolink is very easy to use, creating an efficient research and development tool

用非递归的方法实现二叉树中的层遍历,先序遍历,中序遍历和后序遍历
JWT 登录认证 + Token 自动续期方案,写得太好了!

Can second uncle cure young people's spiritual internal friction?

How to play a data mining game entry Edition

SAP UI5 FileUploader 控件实现本地文件上传,接收服务器端的响应时遇到跨域访问错误的试读版

Socket类关于TCP字符流编程的理解学习

word打字时后面的字会消失是什么原因?如何解决?

酷炫操作预热!代码实现小星球特效
随机推荐
DXF读写:标注样式组码中文说明
R language ggplot2 visualization: use the ggviolin function of ggpubr package to visualize violin diagrams, set the palette parameter, and customize the border colors of violin diagrams at different l
Tutorial on the principle and application of database system (058) -- MySQL exercise (2): single choice question
使用 IPtables 进行 DDoS 保护
111. The sap ui5 fileuploader control realizes local file upload and encounters a cross domain access error when receiving the response from the server
Socket类关于TCP字符流编程的理解学习
R language test sample proportion: use prop The test function performs the single sample proportion test to calculate the confidence interval of the p value of the successful sample proportion in the
Rolling update strategy of deployment.
Generation of tables and contingency tables (cross tables) of R language factor data: use the summary function to analyze the list, view the chi square test results, and judge whether the two factor v
R语言检验样本比例:使用prop.test函数执行单样本比例检验计算总体中成功样本比例p值的置信区间(设置conf.level参数指定置信水平、置信区间的大小)
Deployment之滚动更新策略。
Map tiles: detailed explanation of vector tiles and grid tiles
少儿编程 电子学会图形化编程等级考试Scratch二级真题解析(判断题)2022年6月
数据库系统原理与应用教程(058)—— MySQL 练习题(二):单选题
Excellent performance! Oxford, Shanghai, AI Lab, Hong Kong University, Shangtang, and Tsinghua have joined forces to propose a language aware visual transformer for reference image segmentation! Open
R language uses LM function to build linear regression model and subset function to specify subset of data set to build regression model (use floor function and length function to select the former pa
Cesium pit -- pit used by various API calls and API itself
C语言:归并排序
[ecmascript6] function and its related use
es6你用过哪些惊艳的写法