比赛 noip20081103 评测结果 AWWWWWWWWA
题目名称 放养奶牛 最终得分 20
用户昵称 辨机ZN 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-11-03 21:36:46
显示代码纯文本
program ex(f1,f2);
 type
  ca=record
   x,y:integer;
  end;
  la=array [1..101] of integer;
  zn=array [1..101,0..40] of ca;
  ka=array [1..101,0..40] of real;
 var
  a:zn; w,p,ans:real;
  f1,f2:text; c:ka; s:la;
  i,j,k,m,n,b,l,t,v:longint;
 function juli(x1,y1,x2,y2:integer):real;
  begin
   juli:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
  end;

 begin
  assign(f1,'cowties.in'); reset(f1);
  assign(f2,'cowties.out'); rewrite(f2);
  readln(f1,n);
  for i:=1 to n do
   begin
    read(f1,b); s[i]:=b;
     for j:=1 to b do read(f1,a[i,j].x,a[i,j].y)
   end;

  for i:=1 to s[2] do
   begin
   w:=9999999;
   for j:=1 to s[1] do
    begin
     p:=juli((a[2,i].x),(a[2,i].y),(a[1,j].x),(a[1,j].y));
     if p<w then w:=p;
    end;
   c[2,i]:=w;
   end;
  for t:=3 to n do
   for i:=1 to s[t] do
    begin
     w:=9999999;
     for j:=1 to s[t-1] do
      begin
       p:=juli(a[t,i].x,a[t,i].y,a[t-1,j].x,a[t-1,j].y)+c[t-1,j];
       if p<w then w:=p;
      end;
     c[t,i]:=w;
    end;
 for i:=1 to s[1] do
   begin
   w:=9999999;
   for j:=1 to s[n] do
    begin
     p:=juli(a[1,i].x,a[1,i].y,a[n,j].x,a[n,j].y)+c[n,j];
     if p<w then w:=p;
    end;
   c[1,i]:=w;
   end;

  ans:=99999999;
 for i:=1 to s[1] do
  if c[1,i]<ans then ans:=c[1,i];
 writeln(f2,trunc(ans*100));
 close(f1);
 close(f2);
end.