比赛 2008haoi模拟训练2 评测结果 ETTEE
题目名称 公路建设 最终得分 0
用户昵称 NickName 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-04-23 11:58:07
显示代码纯文本
program nono;
type jl=record
left:integer;
right:integer;
cost:integer;
end;
var xx,xx2:longint;
ri,ro:text;
city:array [1..500] of boolean;
js:longint;
jg:real;
pan:boolean;
road:array[1..500] of jl;
n,m:integer;
procedure go;
var zx1,zx2:longint;
x1,x2:integer;


begin
zx1:=10000;
for x1:=1 to n do
if city[x1]=true then
for x2:=1 to m do
if (((road[x2].left=x1) and (city[road[x2].right]=false)) or
((road[x2].right=x1) and (city[road[x2].left]=false))) and (road[x2].cost<zx1) then
begin
zx1:=road[x2].cost;
zx2:=x2;
end;
city[road[zx2].left]:=true;
city[road[zx2].right]:=true;
js:=js+zx1;
go;
end;
begin
assign(ri,'road.in');
assign(ro,'road.out');
reset(ri);
rewrite(ro);
readln(ri,n,m);
for xx:=1 to n do city[xx]:=false;
for xx:=1 to m do
begin
readln(ri,road[xx].left,road[xx].right,road[xx].cost);
if xx<n-1 then writeln(ro,'0')
else
begin
city[road[1].left]:=true;
js:=0;
go;
pan:=true;
for xx2:=1 to n do
if city[xx2]=false then pan:=false;
if pan=false then writeln(ro,'0');
if pan=true then
begin
jg:=js/0.1;
writeln(ro,js div 2,'.',round(jg));
end;
end;
end;
close(ri);
close(ro);
end.