WA for half a day the result is fast row to double keyword sort. 囧
The main effect of the topic:
Once upon a time there was a king, and the king was greedy, and then he made a wall, which required the least amount of material and a certain distance from the castle. Give you the coordinates of the castle. Let you output this minimum length.
Brief:
is actually a convex package + a circumference with a radius of L.
Attached code:
Program pku_1113; var a,b,c:array[0..3000] of Longint; N,r:longint; {------------------------} procedure qsort (X,y:longint); var g,t,s,l,r:longint; Begin t:=a[(x+y) Div 2]; s:=b[(x+y) Div 2]; L:=x;r:=y; Repeat while (a[l]<t) or (a[l]=t) and (B[l]<s) doing Inc (L); while (a[r]>t) or ((a[r]=t) and (B[r]>s)) does Dec (r); If L<=r then begin g:=a[l];a[l]:=a[r];a[r]:=g; g:=b[l];b[l]:=b[r];b[r]:=g; Inc (L);d EC (R); End Until l>r; If L<y then Qsort (l,y); If X<r then Qsort (x,r); End {------------------------} procedure init; var i:longint; Begin READLN (N,R); For I:=1 to N do readln (A[i],b[i]); Qsort (1,n); End {------------------------} function check (I,j,k:longint): boolean; var Tmp:int64; Begin Tmp:= (A[j]-a[i]) * (B[k]-b[i])-(a[k]-a[i)) * (B[j]-b[i)); If Tmp<0 then exit (false); Exit (TRUE); End {------------------------} procedure main; var i,l:longint; ans:extended; Begin l:=2; c[1]:=1;c[2]:=2; For i:=3 to N Do Begin Inc. (l); c[l]:=i; While not check (C[l-2],c[l-1],c[l]) and (L>2) do begin DEC (l); c[l]:=c[l+1]; End End For i:=n-1 Downto 1 DO BEGIN Inc (L); c[l]:=i; While don't check (C[l-2],c[l-1],c[l]) and (L>2) do begin DEC (l); c[l]:=c[l+1]; End End Ans:=2*pi*r; For I:=1 to L-1 do Ans:=ans+sqrt (SQR (a[c[i]]-a[c[i+1)]) +SQR (b[c[i]]-b[c[i+1])); Writeln (ans:0:0); End {------------------------} begin init; Main end.