比赛 noip20081103 评测结果 AWWWWWWWWA
题目名称 放养奶牛 最终得分 20
用户昵称 Achilles 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-11-03 20:27:52
显示代码纯文本
program cowties;
var
  cow,cow2:array[1..201,0..80]of record
    x,y:longint;
    min:real;
  end;
  n,i,j,k,l:longint;
  t,min:real;
begin
  fillchar(cow,sizeof(cow),0);
  assign(input,'cowties.in');
  assign(output,'cowties.out');
  reset(input);
  rewrite(output);
  readln(n);
  for i:=1 to n do
  begin
    read(cow[i,0].x);
    for j:=1 to cow[i,0].x do
    begin
      read(cow[i,j].x,cow[i,j].y);
      cow[i,j].min:=2147483647;
    end;
    readln;
  end;
  cow2:=cow;
  for i:=1 to cow[1,0].x do
    cow[1,i].min:=0;
  n:=n+1;
  cow[n]:=cow[1];
  cow2:=cow;
  min:=2147483647;
  for l:=1 to cow[1,0].x do
  begin
    cow[1,0].x:=1;
    cow[1,1]:=cow2[1,l];
    cow[n]:=cow[1];
    cow[n,1].min:=2147483647;
    for i:=2 to n do
    begin
      for j:=1 to cow[i,0].x do
        for k:=1 to cow[i-1,0].x do
        begin
          if cow[i,j].min>cow[i-1,k].min+sqrt((cow[i-1,k].x-cow[i,j].x)*(cow[i-1,k].x-cow[i,j].x)+(cow[i-1,k].y-cow[i,j].y)*(cow[i-1,k].y-cow[i,j].y)) then begin
            t:=sqrt((cow[i-1,k].x-cow[i,j].x)*(cow[i-1,k].x-cow[i,j].x)+(cow[i-1,k].y-cow[i,j].y)*(cow[i-1,k].y-cow[i,j].y));
            cow[i,j].min:=cow[i-1,k].min+t;
          end;
        end;
    end;
    if cow[n,1].min<min then min:=cow[n,1].min;
  end;
  writeln(trunc(min*100));
  close(input);
  close(output);
end.