| ||||||||||
| 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 | |||||||||
Re:跪求 大神贴上Pscal版的代码。。。!!!!In Reply To:跪求 大神贴上Pscal版的代码。。。!!!! Posted by:931169987 at 2015-07-24 19:44:49 type
line=record
y,last,cost,level:longint;
end;
var
f:array[0..500] of line;
g:array[0..100,0..100] of longint;
used:array[0..100] of boolean;
n,m,i,en,j,a,b:longint;
procedure dfs(k:longint);
var i:longint;
begin
for i:=1 to n do
if (not used[i])and(g[k,i]>0) then
begin
used[i]:=true;
dfs(i);
if f[i].cost+g[k,i]<f[k].cost then f[k].cost:=f[i].cost+g[k,i];
used[i]:=false;
end;
end;
begin
readln(m,n);
fillchar(used,sizeof(used),false);
for i:=1 to n do
begin
readln(f[i].cost,f[i].level,en);
for j:=1 to en do
begin
readln(a,b); g[i,a]:=b;
end;
if abs(f[i].level-f[1].level)>m then
for j:=1 to n do g[j,i]:=-1;
end;
dfs(1);
writeln(f[1].cost);
end.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator