原创pasal

var
  x1,x2,y1,y2,i,j,max,k1,k2,n,min:longint;
  a,b,c1,c2:array[0..100001]of longint;
procedure
  qsort(l,r:longint);
  var
    i,j,mid,t:longint;
  begin
    mid:=c1[(l+r)div 2];
    i:=l;
    j:=r;
    repeat
      while c1[j]>mid do
        dec(j);
      while c1[i]<mid do
        inc(i);
      if i<=j then
        begin
          t:=c1[i];
          c1[i]:=c1[j];
          c1[j]:=t;
          t:=c2[i];
          c2[i]:=c2[j];
          c2[j]:=t;
          inc(i);
          dec(j);
        end;
    until i>j;
    if j>l then
      qsort(l,j);
    if i<r then
      qsort(i,r);
  end;
begin
  readln(x1,y1,x2,y2);
  readln(n);
  k1:=0;
  k2:=0;
  for i:=1 to n do
    readln(a[i],b[i]);
  for i:=1 to n do
    begin
      c1[i]:=sqr(abs(a[i]-x1))+sqr(abs(b[i]-y1));
      c2[i]:=sqr(abs(a[i]-x2))+sqr(abs(b[i]-y2));
    end;
  qsort(1,n);
  min:=c1[n];
  k2:=0;
  for i:=n-1 downto 1 do
    begin
      k1:=c1[i];
      if c2[i+1]>k2
        then
          k2:=c2[i+1];
      if k1+k2<min then min:=k1+k2;
    end;
  writeln(min);
end.

2 条评论

  • 1

信息

ID
1810
难度
6
分类
(无)
标签
递交数
1606
已通过
443
通过率
28%
被复制
14
上传者