ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1227. Rally Championship

Please, tell me my mistake! WA#4 Code is inside
Posted by Alex Stoff 6 Jun 2006 17:07
I'll delete it after finding mistakes.

Const c:array[boolean] of String[3]=('NO','YES');

Var a:array[1..100,0..100] of longint;
f:array[1..100,1..100] of boolean;
b:array[1..100,1..100] of longint;
fl,cl:array[1..100] of boolean;
n,m,s:longint;
i:longint;
count:longint;

Procedure Output(r:boolean); Forward;

Procedure Input;
Var ot,ku,sk:longint;
i:longint;
Begin
For i:=1 to n do
Begin
If b[ot,ku]>0 then Output(true);
inc(a[ot,0]); a[ot,a[ot,0]]:=ku;
inc(a[ku,0]); a[ku,a[ku,0]]:=ot;
f[ot,ku]:=true; f[ku,ot]:=true;
b[ot,ku]:=sk; b[ku,ot]:=sk;
End;
End;

Procedure Rec(nom:byte; k:longint);
Var j:byte;
Begin
If fl[nom] then Output(true);
If k>count then count:=k;
fl[nom]:=true;
For j:=1 to a[nom,0] do
If f[nom,a[nom,j]] then
Begin
f[nom,a[nom,j]]:=false; f[a[nom,j],nom]:=false;
Rec(a[nom,j],k+b[nom,a[nom,j]]);
f[a[nom,j],nom]:=true; f[nom,a[nom,j]]:=true;
End;
fl[nom]:=false;
End;

Procedure Output(r:boolean); Begin Writeln(c[r]); Halt; End;

BEGIN
Input;
For i:=1 to m do Rec(i,0);
Output(s mod count=0);
END.

WA#4. But If I write Output(false) in the line before last,