第一道凸包
采用Andrew算法,不论实现还是理解都非常简单
var q,x,y:array[..] of longint;
i,j,k,m,n:longint;
ans:double; procedure swap(var a,b:longint);
var c:longint;
begin
c:=a;
a:=b;
b:=c;
end; procedure sort(l,r: longint);
var i,j,p,q: longint;
begin
i:=l;
j:=r;
p:=x[(l+r) shr ];
q:=y[(l+r) shr ];
repeat
while (x[i]<p) or (x[i]=p) and (y[i]<q) do inc(i);
while (p<x[j]) or (p=x[j]) and (q<y[j]) do dec(j);
if not(i>j) then
begin
swap(x[i],x[j]);
swap(y[i],y[j]);
inc(i);
j:=j-;
end;
until i>j;
if l<j then sort(l,j);
if i<r then sort(i,r);
end; function check(i,j,k:longint):longint;
begin
exit((y[i]-y[k])*(x[j]-x[k])-(y[j]-y[k])*(x[i]-x[k]));
end; function calc(i,j:longint):double;
begin
exit(sqrt(sqr(x[i]-x[j])+sqr(y[i]-y[j])));
end; begin
readln(n);
for i:= to n do
readln(x[i],y[i]);
sort(,n);
m:=;
q[]:=;
for i:= to n do
begin
while (m>) and (check(i,q[m],q[m-])<) do dec(m);
inc(m);
q[m]:=i;
end;
k:=m-;
for i:=n- downto do
begin
while (m>k) and (check(i,q[m],q[m-])<) do dec(m);
inc(m);
q[m]:=i;
end;
for i:= to m do
ans:=ans+calc(q[i],q[i-]);
writeln(ans::);
end.