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

Please, help me with this problem!!! PLEASE!!!
Posted by misha 2 Jan 2003 10:15
I can't find "lucki" test to "fall" my program

program Rally_1227;
type city = record
   n : integer;
   a,w : array [1..100] of longint;
end;
var i,j,k,n,m,p,q,s,r,d,kk : longint;
    a : array [1..100] of city;
    c : array [1..100] of longint;
    f : boolean;
begin
   read(m,n,s);
   for i := 1 to n do begin
      read(p,q,r);
      inc(a[p].n);
      a[p].a[a[p].n] := q;
      a[p].w[a[p].n] := r;
      inc(a[q].n);
      a[q].a[a[q].n] := p;
      a[q].w[a[q].n] := r;
   end;
   k := 0;
   for i := 1 to n do begin
      if a[i].n = 0 then k := k+1;
   end;
   if n>=(m-k) then begin
      writeln('YES');
      halt(0);
   end;
   for i := 1 to m do begin
      for j := 1 to m do begin
         c[j] := -1;
      end;
      c[i] := 0;
      while true do begin
      kk := 0;
      for j := 1 to m do begin
         if i = j then continue;
         if a[j].n = 0 then continue;
         if c[j] = -1 then begin
            for d := 1 to a[j].n do begin
               if c[a[j].a[d]] <> -1 then begin
                  if c[j] = -1 then begin
                     c[j] := c[a[j].a[d]]+a[j].w[d];
                     inc(kk);
                  end else begin
                     writeln('YES');
                     halt;
                  end;
               end;
            end;
         end;
      end;
      for j := 1 to m do begin
         if c[j]>=s then begin
            writeln('YES');
            halt;
         end;
      end;
      if kk = 0 then break;
      end;
   end;
   writeln('NO');
end.
i got ac
Posted by misha 2 Jan 2003 12:36
[code deleted]

Edited by moderator 04.12.2019 21:27