program ttdd8;
var cost:array[1..1000,1..1000] of longint;
mincost:array[1..1000] of longint;
sum,min,k,i,j,m,n,x,y,z:longint;
begin
readln(n,m);
fillchar(cost,sizeof(cost),0);
for i:=1 to m do
begin
readln(x,y,z);
if cost[x,y]=0 then
begin
cost[x,y]:=z;
cost[y,x]:=z;
end
else if z<cost[x,y] then
begin
cost[x,y]:=z;
cost[y,x]:=z;
end;
end;
for i:=1 to n do
for j:=1 to n do
if (i<>j) and (cost[i,j]=0) then cost[i,j]:=maxint;
for i:=1 to n do
mincost[i]:=cost[1,i];
for i:=2 to n do
begin
min:=maxint;
for j:=1 to n do
if (mincost[j]<min) and (mincost[j]<>0) then
begin
min:=mincost[j];
k:=j;
end;
inc(sum,min);
mincost[k]:=0;
for j:=1 to n do
if (mincost[j]>cost[k,j]) and (mincost[j]<>0) then
mincost[j]:=cost[k,j];
end;
writeln(sum);
end.
通过本测试点|有效耗时188:ms
测试结果2: 选手程序运行超过时限
测试结果3: 测试结果错误.错误结果为:59271
正确结果应为:139949
测试结果4: 通过本测试点|有效耗时719:ms
测试结果5: 通过本测试点|有效耗时485:ms
测试结果6: 通过本测试点|有效耗时734:ms
测试结果7: 通过本测试点|有效耗时250:ms
测试结果8: 通过本测试点|有效耗时344:ms
测试结果9: 通过本测试点|有效耗时188:ms
测试结果10: 通过本测试点|有效耗时63:ms