比赛 |
10101115 |
评测结果 |
AWWWTTTTTT |
题目名称 |
最小密度路径 |
最终得分 |
10 |
用户昵称 |
magic |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-11-15 11:26:16 |
显示代码纯文本
program gls;
const maxint=10000000;
var
m,n,a,b,w,k,i,j,q,x,y,z,quan:longint;min:real;
st:array[1..50,1..50]of boolean;
ss:array[1..50,1..50]of longint;
data:array[1..100000,1..2]of integer; {}
f,g:text;
procedure make(xx,yy,zz:longint);
var i:integer;
begin
for i:=1 to m do
begin
if (i=y)and(st[xx,i]=true) then
begin quan:=quan+ss[xx,i];
inc(zz);
if min>(quan/zz) then
min:=quan/zz;
quan:=quan-ss[xx,i];
dec(zz);
end;
if (st[xx,i]=true)and(i<>y)then
begin st[xx,i]:=false;
quan:=quan+ss[xx,i];
inc(zz);
make(i,yy,zz);
dec(zz);
quan:=quan-ss[xx,i];
st[xx,i]:=true;
end;
end;
end;
begin
assign(f,'path.in');reset(f);
assign(g,'path.out');rewrite(g);
readln(f,n,m);
fillchar(st,sizeof(st),false);
for k:=1 to m do
begin readln(f,a,b,w);
ss[a,b]:=w;
st[a,b]:=true;
end;
readln(f,q);
for k:=1 to q do
begin z:=0;quan:=0; min:=maxint;
readln(f,x,y);
if x<>y then begin make(x,y,z);
if min<>maxint then writeln(g,min:0:3) else writeln(g,'OMG!');end;
if x=y then writeln(g,'0.000');
end;
close(f);close(g);
end.