比赛 |
noip2016普及练习2 |
评测结果 |
|
题目名称 |
保卫钓鱼岛! |
最终得分 |
0 |
用户昵称 |
bb |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2016-11-07 20:43:16 |
显示代码纯文本
var
m,n,i,j,k,u,v,a,b,t:longint; ans1,ans2,tian:qword;
map:array[1..10000,1..10000]of qword;
begin
assign(input,'diaoyu.in'); reset(input);
assign(output,'diaoyu.out'); rewrite(output);
read(m,n);
tian:=1;
for i:=1 to 63 do tian:=tian*2;
tian:=(tian-1+tian)div 2;
for i:=1 to m do
for j:=1 to m do map[i,j]:=tian;
for i:=1 to m-1 do
begin
read(a,b,t);
map[a,b]:=t;
end;
for i:=1 to m do map[i,i]:=0;
for k:=1 to m do
for i:=1 to m do
for j:=1 to m do
if map[i,k]+map[k,j]<map[i,j] then map[i,j]:=map[i,k]+map[k,j];
for i:=1 to n do
begin
read(u,v);
if map[u,v]<tian then begin inc(ans1);ans2:=ans2+map[u,v];end;
end;
writeln(ans1);
writeln(ans2);
close(input);
close(output);
end.