POJ 2588(解析几何+并查集)
来源:互联网 发布:淘宝app下载 编辑:程序博客网 时间:2024/04/28 19:23
题目就是早从左到右的路
注意输入的实数
这题图画好就行,别像我一开始把图弄反就成
从上开始找,若找到一个与下边界相邻的就无解,找到与左边相邻的记圆与左边界相交的下边的点(相当于左上角挖去一块),右边同理。
Program snake;const maxn=1000;var n,i,j:longint; x,y,r,lc,rc:array[1..maxn] of double; maxl,maxr:double; father:array[1..maxn] of longint; b,up,down,left,right:array[1..maxn] of boolean;function getfather(x:longint):longint;begin if father[x]=x then exit(x); father[x]:=getfather(father[x]); exit(father[x]);end;Procedure union(x,y:longint);begin father[father[x]]:=father[father[y]];end;function distance(i,j:longint):double;begin exit(sqrt(sqr(x[i]-x[j])+sqr(y[i]-y[j])));end;function dis(x1,y1,x2,y2:double):double;begin exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));end;begin fillchar(b,sizeof(b),false); fillchar(up,sizeof(up),false); fillchar(down,sizeof(down),false); fillchar(left,sizeof(left),false); fillchar(right,sizeof(right),false); fillchar(lc,sizeof(lc),0); fillchar(rc,sizeof(rc),0); maxl:=1000;maxr:=1000; read(n); for i:=1 to n do begin read(x[i],y[i],r[i]); father[i]:=i; for j:=1 to i-1 do if distance(i,j)<r[i]+r[j] then if getfather(i)<>getfather(j) then union(i,j); if (y[i]<r[i]) then down[i]:=true; if (y[i]+r[i]>1000) then up[i]:=true; if (x[i]<r[i]) then begin left[i]:=true; lc[i]:=y[i]-sqrt(sqr(r[i])-sqr(x[i])); end; if (x[i]+r[i]>1000) then begin right[i]:=true; rc[i]:=y[i]-sqrt(sqr(r[i])-sqr(1000-x[i])); end; end; for i:=1 to n do if (up[i]) and not(b[i]) then begin for j:=1 to n do if father[i]=father[j] then begin b[j]:=true; if (down[j]) then begin writeln('Bill will be bitten.'); halt; end; if left[j] then begin if lc[j]<maxl then maxl:=lc[j]; end; if right[j] then begin if rc[j]<maxr then maxr:=rc[j]; end; end; end; writeln('Bill enters at (0.00, ',maxl:2:2,') and leaves at (1000.00, ',maxr:2:2,').');end.
- POJ 2588(解析几何+并查集)
- POJ 1375 Intervals(解析几何)
- Poj 并查集
- poj并查集
- POJ 并查集
- POJ 2588 Snakes 并查集
- POJ 1611(并查集)
- poj 1611 (并查集)
- 种类并查集(POJ 1703)
- poj 1182食物链(并查集)
- POJ - 1182 食物链(并查集)
- POJ 1182食物链(并查集)
- POJ-2524(并查集)
- POJ 1182 :食物链(并查集)
- POJ-1611(并查集)
- poj 1182(并查集)
- POJ 1838 Banana (并查集)
- poj 1182(食物链)并查集
- gtags error: curses library is required but not found.
- 流年,经不起怀念
- IT人不要一辈子靠技术
- HashMap与Hashtable的区别
- hdu 1229 水的不用看的一个大水题
- POJ 2588(解析几何+并查集)
- mdev的使用以及mdev.conf的规则配置--busybox
- Solves nonlinear least-squares curve fitting problems of the form
- OSI七层模型和TCP/IP五层模型详讲
- PL/SQL专家指南3——调用者权限和定义者权限 上篇
- 2012 ACM/ICPC 杭州赛区网络赛Super Mario
- cc2430 DMA及IRQMASK问题解析
- 流年,经不起怀念
- java biginterger的相关函数作用