Help!
Posted by
qaztz 29 Mar 2002 17:37
I got wa.:(
Here is my program:
{$q+,n+}
var n,l,a,c,ee:longint; tot:extended;
b,d:array[0..1000,1..2] of longint;
e:array[1..1001] of longint;
function z(a1:longint):boolean;
var b1,c1,d1,e1:longint;
begin
b1:=b[e[a1],1]-b[e[a1-1],1]; c1:=b[e[a1],2]-b[e[a1-1],2];
d1:=b[e[a1-1],1]-b[e[a1-2],1]; e1:=b[e[a1-1],2]-b[e[a1-2],2];
if b1*e1-c1*d1<=0 then z:=true
else z:=false;
end;
begin
assign(input,''); reset(input);
assign(output,''); rewrite(output);
read(n,l);
for a:=1 to n do read(b[a,1],b[a,2]);
c:=1;
for a:=2 to n do
if (b[a,1]<b[c,1])or(b[a,1]=b[c,1])and(b[a,2]<b[c,2]) then c:=a;
d:=b;
for a:=c to n do b[a-c+1]:=d[a];
for a:=1 to c-1 do b[n-c+1+a]:=d[a];
e[1]:=1; ee:=1;
for a:=2 to n do begin
inc(ee); e[ee]:=a;
while (ee>2)and z(ee) do begin
e[ee-1]:=e[ee]; dec(ee);
end;
end;
tot:=2*pi*l;
e[ee+1]:=e[1];
for a:=1 to ee do
tot:=tot+sqrt(sqr(b[e[a],1]-b[e[a+1],1])+sqr(b[e[a],2]-b[e
[a+1],2]));
writeln(tot:0:0);
close(input); close(output);
end.
Thank you!