比赛 |
2008haoi模拟训练1 |
评测结果 |
AWWEEEEEEE |
题目名称 |
水管局长 |
最终得分 |
10 |
用户昵称 |
cuixiaofei |
运行时间 |
1.153 s |
代码语言 |
Pascal |
内存使用 |
17.38 MiB |
提交时间 |
2008-04-22 10:11:05 |
显示代码纯文本
//na :cuixiaofei;
//da :08_04_22;
program tube;
var
a,c :array[0..1500,0..1500{1500}] of longint;
n,m,q :longint;
f1,f2 :text;
procedure jinru(x,y:longint;var zuixiao:longint);
var
b,ji :array[1..1500,1..2] of longint;
i,j,s,ge :longint;
begin
fillchar(ji,sizeof(b),0);
zuixiao:=maxlongint;
s:=1;
b[1,1]:=x;
ge:=1;
while s<=ge do
begin
while (b[s,1]=y) do
begin
if zuixiao>b[s,2] then
zuixiao:=b[s,2];
inc(s);
end;
for i:=1 to n do
if (c[b[s,1],i]=1) then
begin
inc(ge);
b[ge,1]:=i;
if a[b[s,1],i]>b[s,2] then
b[ge,2]:=a[b[s,1],i]
else
b[ge,2]:=b[s,2];
c[b[s,1],i]:=0;
c[i,b[s,1]]:=0;
end;
inc(s);
end;
end;
procedure init;
var
i,j,a1,a2,k,x,y,min,i1 :longint;
begin
assign(f1,'tube.in');
reset(f1);
assign(f2,'tube.out');
rewrite(f2);
fillchar(a,sizeof(a),0);
readln(f1,n,m,q);
for i:=1 to m do
begin
readln(f1,a1,a2,a[a1,a2]);
a[a2,a1]:=a[a1,a2];
end;
for i1:=1 to q do
begin
read(f1,k);
if k=2 then
begin
readln(f1,x,y);
a[x,y]:=0;
end
else
begin
readln(f1,x,y);
for i:=1 to n do
for j:=1 to n do
if a[i,j]<>0 then
c[i,j]:=1
else
c[i,j]:=0;
jinru(x,y,min);
writeln(f2,min);
end;
end;
close(f1);
close(f2);
end;
procedure main;
begin
init;
end;
begin
main;
end.