比赛 20101118 评测结果 C
题目名称 扩散 最终得分 0
用户昵称 王者自由 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-11-18 11:05:34
显示代码纯文本
program ppg;
type tu=record x,y:longword; end;
var n,i,s,t1,t2,x1,x2,y1,y2:longword;
  A:array of tu;
procedure Qsort(l,r:longword);
var i,j,x:longword; y:tu;
begin
  i:=l; j:=r; x:=A[(l+r) div 2].x;
  repeat
    while A[i].x<x do inc(i);
    while x<A[j].x do dec(j);
    if not(i>j) then
    begin
      y:=A[i]; A[i]:=A[j]; A[j]:=y;
      inc(i); dec(j);
    end;
  until i>j;
  if l<j then Qsort(l,j);
  if i<r then Qsort(i,r);
end;
function max(a,b:longword):longword;
begin
  if a>b then exit(a) else exit(b);
end;
function max(a,b,c:longword):longword;
begin
  exit(max(a,max(b,c)));
end;
begin
  assign(input,'ppg.in'); reset(input);
  assign(output,'ppg.out'); rewrite(output);
  readln(n);
  setlength(A,n+1);
  for i:=1 to n do readln(A[i].x,A[i].y);
  Qsort(1,n); for i:=1 to n do writeln(A[i].x,' ',A[i].y);
  s:=0;
  if n=1 then s:=0;
  if n=2 then s:=max(abs(A[1].x-A[2].x)div 2,abs(A[1].y-A[2].y)div 2);
  if (n=2)and(A[1].x=0) then s:=max(A[2].x,A[2].y);
  for i:=2 to n-1 do
  begin
    x1:=abs(A[i].x-A[i+1].x); x2:=abs(A[i-1].x-A[i].x);
    y1:=abs(A[i].y-A[i+1].y); y2:=abs(A[i-1].y-A[i].y);
    t1:=sqr(x1)+sqr(y1);
    t2:=sqr(x2)+sqr(y2);
    if t1<t2
      then s:=max(s,x1 div 2,y1 div 2)
      else if A[i-1].x=0
        then s:=max(s,x2,y2)
        else s:=max(s,x2 div 2,y2 div 2);
  end;
  writeln(s);
  close(input); close(output);
end.