比赛 |
2008haoi模拟训练1 |
评测结果 |
AAATTTTTTT |
题目名称 |
水管局长 |
最终得分 |
30 |
用户昵称 |
thegy |
运行时间 |
22.893 s |
代码语言 |
Pascal |
内存使用 |
7.82 MiB |
提交时间 |
2008-04-22 10:43:18 |
显示代码纯文本
program tube;
var
fin,fout:text;
i,j,n,m,q,a,b,c,k,ii,t,flag:longint;
g,g0:array[1..1000,1..1000]of longint;
function max(x,y:longint):longint;
begin
if x>y then max:=x
else max:=y;
end;
begin
assign(fin,'tube.in'); reset(fin);
assign(fout,'tube.out'); rewrite(fout);
read(fin,n,m,q);
for i:=1 to n do
for j:=1 to n do g[i,j]:=9999999;
for i:=1 to m do
begin
readln(fin,a,b,c);
g[a,b]:=c;
g[b,a]:=c;
end;
for i:=1 to n do
for j:=1 to n do g0[i,j]:=g[i,j];
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
begin
if i=j then continue;
t:=max(g0[i,k],g0[k,j]);
if t<g0[i,j] then g0[i,j]:=t;
end;
for ii:=1 to q do
begin
readln(fin,flag,a,b);
if flag=1 then writeln(fout,g0[a,b])
else
begin
g[a,b]:=9999999;
g[b,a]:=9999999;
for i:=1 to n do
for j:=1 to n do g0[i,j]:=g[i,j];
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
begin
if i=j then continue;
t:=max(g0[i,k],g0[k,j]);
if t<g0[i,j] then g0[i,j]:=t;
end;
end;
end;
close(fout);
end.