| ||||||||||
| 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 p3594;
const maxn=100;
maxt=10000;
type node=record
size:longint;
b,e,c:array[1..50] of longint;
end;
var n,m,s,t,i,j,k,ans,x,y:longint;
a:array[1..maxn,1..maxn] of node;
f:array[1..maxn,0..maxt] of longint;
begin
readln(n,m,s,t);
fillchar(a,sizeof(a),0);
for i:=1 to m do begin
read(x,y);
inc(a[x,y].size);
readln(a[x,y].b[a[x,y].size],a[x,y].e[a[x,y].size],a[x,y].c[a[x,y].size]);
if a[x,y].e[a[x,y].size]-a[x,y].b[a[x,y].size]<a[x,y].c[a[x,y].size] then dec(a[x,y].size);
end;
fillchar(f,sizeof(f),255);
for i:=0 to maxt do f[s,i]:=i;
for k:=0 to maxt do
for i:=1 to n do
if (i<>s) then
for j:=1 to n do
if (a[j,i].size<>0) then
for m:=1 to a[j,i].size do
if (k<=a[j,i].e[m]) and (k-a[j,i].c[m]>=a[j,i].b[m]) and (f[j,k-a[j,i].c[m]]<>-1) then
if f[j,k-a[j,i].c[m]]>f[i,k] then f[i,k]:=f[j,k-a[j,i].c[m]];
ans:=maxlongint;
for i:=0 to maxt do
if f[t,i]<>-1 then
if i-f[t,i]<ans then ans:=i-f[t,i];
if ans=maxlongint then writeln('Impossible') else writeln(ans);
end.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator