比赛 |
noip20081103 |
评测结果 |
AATTTTTTTA |
题目名称 |
放养奶牛 |
最终得分 |
30 |
用户昵称 |
王瑞祥K |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-11-03 21:31:46 |
显示代码纯文本
program cowties(input,output);
type
point=record
x,y:integer;
end;
var
map:array[-100..100,-100..100]of boolean;
a:array[1..100,1..40]of point;
s:array[1..100]of integer;
b:array[1..100]of point;
n:integer;
min:longint;
procedure ini;
var i,j:integer;
begin
assign(input,'cowties.in');assign(output,'cowties.out');
reset(input);rewrite(output);
readln(n);
for i:=1 to n do begin
read(s[i]);
for j:=1 to s[i] do read(a[i,j].x,a[i,j].y);
readln;
end;
fillchar(map,sizeof(map),true);
min:=999999999;
end;
procedure search(dep:integer);
var i,j:integer;tot:real;
begin
if dep=n+1 then begin
tot:=0;
for i:=2 to n do
tot:=tot+sqrt(sqr(b[i].x-b[i-1].x)+sqr(b[i].y-b[i-1].y));
tot:=tot+sqrt(sqr(b[1].x-b[n].x)+sqr(b[1].y-b[n].y));
if trunc(tot*100)<min then min:=trunc(tot*100);
end
else begin
for i:=1 to s[dep] do
if map[a[dep,i].x,a[dep,i].y] then begin
map[a[dep,i].x,a[dep,i].y]:=false;
b[dep].x:=a[dep,i].x;
b[dep].y:=a[dep,i].y;
search(dep+1);
map[a[dep,i].x,a[dep,i].y]:=true;
end;
end;
end;
begin
ini;
search(1);
write(min);
close(input);close(output);
end.