比赛 noip20081103 评测结果 AWTTTTTTTW
题目名称 放养奶牛 最终得分 10
用户昵称 cuixiaofei 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-11-03 21:54:31
显示代码纯文本
//na                            :cuixiaofei;
//da                            :08_11_03;
program cowties;
  type
    sss                         =record
                         zb     :array[1..50,1..2] of real;
                         ge     :longint;
                                end;
  var
    n                           :longint;
    min                         :real;
    a                           :array[0..300] of sss;
    f1,f2                       :text;
  procedure init;
    var
      i,j                       :longint;
  begin
    assign(f1,'cowties.in');
    reset(f1);
    assign(f2,'cowties.out');
    rewrite(f2);
    min:=100000000000;
    readln(f1,n);
    for i:=1 to n do
      begin
        read(f1,a[i].ge);
        for j:=1 to a[i].ge do
          read(f1,a[i].zb[j,1],a[i].zb[j,2]);
      end;
  end;
  function jisuan(x1,y1,x2,y2:real):real;
  begin
    jisuan:=sqrt(sqr(x1-x2)+sqr(y1-y2));
  end;
  procedure sousuo(k,gg:longint;he:real);
    var
      i                         :longint;
      x,y                       :real;
  begin
    if k>n then
      begin
        if he+jisuan(a[k-1].zb[gg,1],a[k-1].zb[gg,2],a[0].zb[1,1],a[0].zb[1,2])<min then
          begin
            min:=he+jisuan(a[k-1].zb[gg,1],a[k-1].zb[gg,2],a[0].zb[1,1],a[0].zb[1,2]);
          end;
      end
    else
      begin
        for i:=1 to a[k].ge do
          begin
            if k=1 then
              begin
                a[0].zb[1,1]:=a[k].zb[i,1];
                a[0].zb[1,2]:=a[k].zb[i,2];
              end;
            x:=a[k].zb[i,1];
            y:=a[k].zb[i,2];
            if (he+jisuan(x,y,a[k-1].zb[gg,1],a[k-1].zb[gg,2])<min) then
               sousuo(k+1,i,he+jisuan(x,y,a[k-1].zb[gg,1],a[k-1].zb[gg,2]));
          end;
      end;
  end;
  procedure main;
  begin
    sousuo(1,1,0);
  end;
  procedure print;
  begin
    writeln(f2,min*100:0:0);
    close(f1);
    close(f2);
  end;
  begin
    init;
    main;
    print;
  end.