当前位置:网站首页>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;
}
边栏推荐
- [ecmascript6] function and its related use
- UVA1599理想路径题解
- Some thoughts on.Net desktop development
- 7. Dependency injection
- 国产API管理工具Eolink太好用了,打造高效的研发利器
- 拒绝服务 DDoS 攻击
- C language: random number + quick sort
- The domestic API management tool eolink is very easy to use, creating an efficient research and development tool
- Org.apache.ibatis.exceptions.toomanyresultsexception
- 基于神经网络的帧内预测和变换核选择
猜你喜欢

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

How to play a data mining game entry Edition

最强分布式锁工具:Redisson

After finishing, help autumn move, I wish you call it an offer harvester

用非递归的方法实现二叉树中的层遍历,先序遍历,中序遍历和后序遍历

国产API管理工具Eolink太好用了,打造高效的研发利器
![[security] read rfc6749 and understand the authorization code mode under oauth2.0](/img/dc/e6d8626195b2e09a6c06050a9b552e.jpg)
[security] read rfc6749 and understand the authorization code mode under oauth2.0

Children's programming electronic society graphical programming level examination scratch Level 2 real problem analysis (judgment question) June 2022

30 day question brushing plan (IV)

Strict mode -- let and const -- arrow function -- Deconstruction assignment -- string template symbol -- set and map -- generator function
随机推荐
R语言可视化散点图、使用ggrepel包的geom_text_repel函数避免数据点之间的标签互相重叠(使用参数xlim和ylim将标签添加到可视化图像的特定区域、指定标签线段并添加箭头)
力扣 剑指 Offer 51. 数组中的逆序对
Jenkins -- continuous integration server
Beyond Istio OSS——Istio服务网格的现状与未来
SQL每日一练(牛客新题库)——第4天:高级操作符
面经整理,助力秋招,祝你称为offer收割机
30天刷题训练(一)
I'm bald! Who should I choose for unique index or general index?
R language uses LM function to build multiple linear regression model, writes regression equation according to model coefficient, and uses conflict function to give 95% confidence interval of regressi
DXF读写:对齐尺寸标注文字居中、上方的位置计算
LyScript 获取上一条与下一条指令
.net for subtraction, intersection and union of complex type sets
PHP generates random numbers (nickname random generator)
Remember to use pdfbox once to parse PDF and obtain the key data of PDF
vite在项目中配置路径别名
C语言:顺序存储结构的快速排序
Realize the mutual value transfer between main window and sub window in WPF
数据库系统原理与应用教程(061)—— MySQL 练习题:操作题 21-31(五)
No swagger, what do I use?
SAP UI5 FileUploader 控件实现本地文件上传,接收服务器端的响应时遇到跨域访问错误的试读版