bzoj2829

时间:2022-01-05 16:32:41

裸题,直接上凸包,然后加上一个圆周即可

只是在这之前没写过旋转而已

 const pi=3.14159265358979323;
eps=1e-8;
type point=record
x,y:double;
end; var p:array[..] of point;
q:array[..] of longint;
n,i,k,t:longint;
ans,a,b,x,y,an,r:double; procedure swap(var a,b:point);
var c:point;
begin
c:=a;
a:=b;
b:=c;
end; function cmp(a,b:point):boolean;
begin
if abs(a.x-b.x)<eps then exit(a.y<b.y);
exit(a.x<b.x);
end; procedure sort(l,r:longint);
var i,j:longint;
x:point;
begin
i:=l;
j:=r;
x:=p[(l+r) shr ];
repeat
while cmp(p[i],x) do inc(i);
while cmp(x,p[j]) do dec(j);
if not(i>j) then
begin
swap(p[i],p[j]);
inc(i);
dec(j);
end;
until i>j;
if l<j then sort(l,j);
if i<r then sort(i,r);
end; function cross(i,j,k:longint):double;
begin
exit((p[i].x-p[k].x)*(p[j].y-p[k].y)-(p[j].x-p[k].x)*(p[i].y-p[k].y));
end; function dis(i,j:longint):double;
begin
exit(sqrt(sqr(p[i].x-p[j].x)+sqr(p[i].y-p[j].y)));
end; function get(x,y,x0,y0:double):point;
begin
get.x:=cos(an)*x-sin(an)*y+x0;
get.y:=sin(an)*x+cos(an)*y+y0;
end; begin
readln(n);
readln(b,a,r);
a:=a-*r;
b:=b-*r;
for i:= to n do
begin
readln(x,y,an);
inc(t); p[t]:=get(a/,-b/,x,y);
inc(t); p[t]:=get(a/,b/,x,y);
inc(t); p[t]:=get(-a/,b/,x,y);
inc(t); p[t]:=get(-a/,-b/,x,y);
end;
sort(,t);
n:=t;
t:=;
q[]:=;
for i:= to n do
begin
while (t>) and (cross(i,q[t],q[t-])>=-eps) do dec(t);
inc(t);
q[t]:=i;
end;
k:=t;
for i:=n- downto do
begin
while (t>k) and (cross(i,q[t],q[t-])>=-eps) do dec(t);
inc(t);
q[t]:=i;
end;
for i:= to t do
ans:=ans+dis(q[i],q[i-]); writeln(ans+*r*pi::);
end.

相关文章