What's wrong whith my program?
What's wrong whith my program?
var m:word;
s:longint;
a:array[1..100,1..100] of longint;
procedure init;
var i,temp1,temp2,temp3,n:longint;
begin
readln(m,n,s);
fillchar(a,sizeof(a),0);
for i:=1 to n do
begin
readln(temp1,temp2,temp3);
a[temp1,temp2]:=temp3;
a[temp2,temp1]:=temp3;
end;
end;
procedure done;
begin
writeln('YES');
halt;
end;
procedure main;
var reach:array[1..100] of boolean;
x:array[1..200,1..3] of longint;
open,closed,start,i:word;
begin
for start:=1 to m do
begin
fillchar(reach,sizeof(reach),false);
reach[start]:=true;
open:=0;
closed:=1;
x[1,1]:=start;
x[1,2]:=0;
x[1,3]:=0;
while open<closed do
begin
inc(open);
for i:=1 to m do
if (a[x[open,1],i]>0) and (i<>x[open,3]) then
begin
if (x[open,2]+a[x[open,1],i])>=s then done;
if reach[i] then done;
inc(closed);
x[closed,1]:=i;
x[closed,2]:=x[open,2]+a[x[open,1],i];
x[closed,3]:=x[open,1];
end;
end;
end;
writeln('NO');
end;
begin
init;
main;
end.