| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
奇怪,全部换成长整就过了。program ex;
var
a,b:array[1..100,1..100] of real;
c:array[1..100,1..100] of longint;
aa:array[1..100] of longint;
d:array[1..100] of real;
f:array[1..100] of boolean;
level:array[1..100] of longint;
q:array[1..10001] of longint;
n,m,v:longint;
r1,r2,c1,c2,t,s:real;
i,t1,t2,l,r:longint;
begin
fillchar(level,sizeof(level),0);
fillchar(f,sizeof(f),0);
readln(n,m,v,s);
for i:=1 to n do aa[i]:=0;
for i:=1 to m do
begin
readln(t1,t2,r1,c1,r2,c2);
inc(aa[t1]);
a[t1,aa[t1]]:=r1;
b[t1,aa[t1]]:=c1;
c[t1,aa[t1]]:=t2;
inc(aa[t2]);
a[t2,aa[t2]]:=r2;
b[t2,aa[t2]]:=c2;
c[t2,aa[t2]]:=t1;
end;
for i:=1 to n do d[i]:=-10000000;
d[v]:=s;
l:=0;
r:=1;
q[1]:=v;
f[v]:=true;
level[v]:=1;
while l<r do
begin
inc(l);
t1:=q[l];
f[t1]:=false;
for i:=1 to aa[t1] do
begin
t2:=c[t1,i];
t:=(d[t1]-b[t1,i])*a[t1,i];
if t<0 then continue;
if t>d[t2] then
begin
d[t2]:=t;
if not f[t2] then
begin
inc(r);
q[r]:=t2;
f[t2]:=true;
level[t2]:=level[t1]+1;
if level[t2]>n then
begin
writeln('YES');
exit;
end;
end;
end;
end;
end;
writeln('NO');
end.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator