比赛 20110723 评测结果 EEEEEE
题目名称 圣诞节 最终得分 0
用户昵称 donny 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2011-07-23 12:39:58
显示代码纯文本
program christmas;
type
  s=record
    x,y:longint;
  end;
var
  i,j,k,l:longint;
  n:longint;
  a:array[1..500]of longint;
  b:array[1..500]of boolean;
  nan,nv:array[1..500]of s;
  min:longint;

procedure search(x:longint);
var
  i,j,k:longint;
begin
  if x=n+1 then
  begin
    k:=0;
    for i:=1 to n do
    begin
      j:=sqr(nan[i].x-nv[a[i]].x)+sqr(nan[i].y-nv[a[i]].y);
      if j>k then k:=j;
    end;
    if k<min then
      min:=k;
  end
  else
  begin
    for i:=1 to n do
      if b[i]=false then
      begin
        a[x]:=i;
        b[i]:=true;
        search(x+1);
        b[i]:=false;
        a[x]:=0;
      end;
  end;
end;

begin
  assign(input,'christmas.in');
  reset(input);
  assign(output,'christmas.out');
  rewrite(output);

  readln(n);
  for i:=1 to n do
    readln(nan[i].x,nan[i].y);
  for i:=1 to n do
    readln(nv[i].x,nv[i].y);
  min:=99999999;

  search(1);

  writeln(min);

  close(input);
  close(output);
end.