| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
求大神指教,不明原因错误的半平面交crossing——求交点
cross——叉积
ttl——判断点是否在半平面内
in180——判断两条叉积是否为正(在180度以内)
dt——队列
e——待插入半平面
主体
function can(r:extended):boolean;
var l:extended;
i,st,en:longint;
ans:boolean;
begin
for i:=1 to n do begin
l:=sqrt(sqr(e[i].x.x)+sqr(e[i].x.y));
e[i].p.x:=e[i].p.x+r/l*(-e[i].x.y);
e[i].p.y:=e[i].p.y+r/l*e[i].x.x;
end;
st:=1;en:=2;dt[1]:=e[1];dt[2]:=e[2];ans:=true;
for i:=3 to n do begin
while (st<en) and in180(dt[en-1].x,e[i].x) and ttl(crossing(e[i],dt[en-1]),dt[en]) do dec(en);
while (st<en) and in180(e[i].x,dt[st+1].x) and ttl(crossing(e[i],dt[st+1]),dt[st]) do inc(st);
if st<en then
if (cross(e[i].x,dt[st+1].x)=0)and not ttl(e[i].p,dt[st+1]) or
((cross(e[i].x,dt[en-1].x)=0)and not ttl(e[i].p,dt[en-1])) or
(in180(dt[st].x,dt[en].x) and not ttl(crossing(dt[en],dt[st]),e[i])) then begin
ans:=false;break;
end;
if (st=en) or not in180(dt[en].x,dt[st].x) or not ttl(crossing(dt[st],dt[en]),e[i]) then begin
inc(en);dt[en]:=e[i];
end;
end;
can:=ans;
e:=ne;
end;
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator