比赛 |
noip20081103 |
评测结果 |
EAEEEEEEEA |
题目名称 |
放养奶牛 |
最终得分 |
20 |
用户昵称 |
elysian |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-11-03 21:55:26 |
显示代码纯文本
program elysian;
type
node=record
x,y:integer;
end;
const
fin='cowties.in';fout='cowties.out';
var
f1,f2:text;
ans:real;
s:array[1..40] of integer;
f:array[0..100] of real;
a:array[0..100,0..40] of node;
n:longint;
//f[i]:=f[i-1]+dis(a[i].x,a[i],y,a[i-1].x,a[i-1].y)
function dis(x1,y1,x2,y2:integer):real;
var
t1,t2:integer;
begin
t1:=(x1-x2)*(x1-x2);
t2:=(y1-y2)*(y1-y2);
dis:=sqrt(t1+t2);
end;
procedure main;
var
min:real;
i,j,t,t1:longint;
begin
for i:=1 to n do
begin
min:=maxlongint;
for j:=1 to s[i] do
if min>f[i-1]+dis(a[i,j].x,a[i,j].y,a[i-1,t].x,a[i-1,t].y) then
begin
min:=f[i-1]+dis(a[i,j].x,a[i,j].y,a[i-1,t].x,a[i-1,t].y);
t:=j;
if i=1 then t1:=j;
end;
f[i]:=min;
end;
ans:=f[n]+dis(a[1,t1].x,a[1,t1].y,a[n,t].x,a[n,t].y);
assign(f2,fout);rewrite(f2);
writeln(f2,trunc(ans*100));
close(f2);
end;
procedure init;
var
i,j:longint;
begin
assign(f1,fin);reset(f1);
readln(f1,n);
for i:=1 to n do
begin
read(f1,s[i]);
for j:=1 to s[i] do read(f1,a[i,j].x,a[i,j].y);
end;
close(f1);
end;
begin
init;
main;
end.