比赛 |
20110727 |
评测结果 |
AAAAAAAAA |
题目名称 |
道路重建 |
最终得分 |
100 |
用户昵称 |
WSJZX |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2011-07-27 11:43:10 |
显示代码纯文本
program rebuild;
var
i,j,n,m,t,total,ans,k,x,y,d,s1,s2:longint;
a:array[0..10000,0..3] of longint;
f:array[0..10000] of boolean;
b:array[0..500,0..500] of longint;
procedure find(x,y:longint);
var
i,j:longint;
begin
for i:=1 to m do
if ((x=a[i,1])and(y=a[i,2]))or((x=a[i,2])and(y=a[i,1])) then
begin
f[i]:=true;
exit;
end;
end;
begin
assign(input,'rebuild.in');reset(input);
assign(output,'rebuild.out');rewrite(output);
fillchar(b,sizeof(b),10);
fillchar(f,sizeof(f),false);
readln(n);
readln(m);
for i:=1 to m do
for j:=1 to 3 do
read(a[i,j]);
readln(d);
for i:=1 to d do
begin
readln(x,y);
find(x,y);
end;
readln(s1,s2);
for i:=1 to m do
if f[i] then
begin
b[a[i,1],a[i,2]]:=a[i,3];
b[a[i,2],a[i,1]]:=a[i,3];
end
else
begin
b[a[i,1],a[i,2]]:=0;
b[a[i,2],a[i,1]]:=0;
end;
for k:=1 to n do
for i:=1 to n do
if k<>i then
for j:=1 to n do
if (i<>j)and(j<>k) then
if b[i,k]+b[k,j]<b[i,j] then
b[i,j]:=b[i,k]+b[k,j];
writeln(b[s1,s2]);
close(input);close(output);
end.