ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1227. Rally Championship

What's wrong whith my program?
Posted by Sniper-007 15 Nov 2002 15:02
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.
Test for you
Posted by Algorithmus_UA(algorithmus@univ.kiev.ua) 16 Nov 2002 13:52
2 2 3
1 2 1
1 2 1
Graph can be multigraph! So answer is 'YES', but your program
gived 'NO'.
Thanks.
Posted by Sniper-007 17 Nov 2002 05:24
I got AC.
Thank you very much.