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 1176. Hyperchannels

Does the Eulerian cycle always exist?
Posted by Teragram 18 May 2004 15:04
I got WA on test 3.
Here is my code:


Program ex;
Const Rule              :Array [0..7] Of Integer
                        =(1,2,4,8,16,32,64,128);
Var G                   :Array [1..1001,0..125] Of Byte;
    Len,M               :Integer;
    St,Ar               :Array [1..32010] Of Integer;
    N,Be                :Integer;
Procedure Init;
Var P,Q,U               :Integer;
Begin
  Readln(N,Be);
  For P:=1 To N Do
    For Q:=1 To N Do Begin
      Read(U);
      If (U=0) And (P<>Q) Then Inc(G[P,(Q-1) Div 8],Rule[(Q-1) Mod 8]);
    End;
End;
Procedure Main;
Var I,J                 :Integer;
Begin
  M:=0;
  Len:=1;
  St[1]:=Be;
  Repeat
    I:=St[Len];
    J:=1;
    Repeat
      If G[I,(J-1) Div 8] And Rule[(J-1) Mod 8]>0 Then Break;
      Inc(J);
    Until J>N;
    If J<=N Then Begin
      Dec(G[I,(J-1) Div 8],Rule[(J-1) Mod 8]);
      Inc(Len);
      St[Len]:=J;
    End Else Begin
      Dec(Len);
      Inc(M);
      Ar[M]:=I;
    End;
  Until Len=0;
  If Ar[1]<>Be Then Begin
    Repeat
    Until False;
  End;
  For I:=1 To M-1 Do Writeln(Ar[I],' ',Ar[I+1]);
End;
Begin
  Init;
  Main;
End.
I got WA on test 2.............
Posted by hello 18 May 2004 22:33
I can't find my mistake........
Who can give me some test........
This is my code :
--------------------------------------------------------

const
  Maxn = 1010 ;
var
  h : Array [0..Maxn,0..100] Of Integer ;
  l : Array [0..Maxn] Of Integer ;
  list : Array [0..66000] Of Integer ;
  len , n , first , x : LongInt ;

  procedure init ;
    var
      i , j , k : Integer ;
    begin
     read ( n , first ) ;
     for i := 1 to n do
      for j := 1 to n do
       begin
        read ( k ) ;
        if ( k = 0 ) and ( i <> j ) then
         begin
          Inc ( l[i] ) ;
          h[i,l[i]] := j ;
         end;
       end;
    end;

  procedure Dfs ( k : Integer ) ;
    begin
     While l[k] > 0 do
      begin
       Dec ( l[k] ) ;
       Dfs ( h[k,l[k]+1] ) ;
      end;
     Inc ( len ) ;
     list[len] := k ;
    end;

  procedure out ;
    var
      i : LongInt ;
    begin
     if n > 1 then
      begin
       write ( list[1] ) ;
       for i := 2 to len - 1 do
        begin
         writeln ( ' ' , list[i] ) ;
         write ( list[i] ) ;
        end;
       writeln ( ' ' , list[len] ) ;
      end;
    end;

begin
 init ;
 Dfs ( first ) ;
 out  ;
end.
Re: WA#3
Posted by Sergey Baskakov, Raphail and Denis 13 Mar 2005 10:02
I was getting WA3 until understood, that my program gives a wrong output on the following test:
3 2
0 0 1
1 0 0
0 1 0
To my mind, the only possible answer is as follows:
2 3
3 1
1 2
And my old solution output just the opposite, i.e.
2 1
1 3
3 2
Good luck (!

rafailka.

Edited by author 13.03.2005 10:02
Re: WA#3
Posted by Yu Xin 2 Jun 2005 18:29
Thanks.