|
|
back to boardHelp!!!!!!!!11Why I got 'wrong answer'???????? Posted by Lin 22 Feb 2002 21:55 Const P : Array[0..7] of Byte= (1,2,4,8,16,32,64,128); Type Arr = Array[0..125] of Byte; Var N,M : Integer; Map : Array[1..1000] of ^Arr; Total : Integer; Procedure Init; Var i,j : Integer; R : Integer; Begin Readln(N,M); For i := 1 to N do Begin New(Map[i]); Fillchar(Map[i]^,Sizeof(Map[i]^),0); For j := 1 to N do Begin Read(R); R := 1-R; Map[i]^[j Div 8] := Map[i]^[j Div 8] Or (P[j Mod 8]*R); End; End; End; Procedure Print; Var i : Integer; Quit : Boolean; Begin Repeat Quit := True; For i := 1 to N do If i<>M then If Map[M]^[i Div 8] and P[i Mod 8]<>0 then Begin Dec(Map[M]^[i Div 8],P[i Mod 8]); Writeln(M,' ',i); M := i; Quit := False; Break; End; Until Quit; End; Begin Init; Print; End. Re: Help!!!!!!!!11Why I got 'wrong answer'???????? Posted by Igor 23 Feb 2002 18:31 Try Such an input: 4 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 If i'm not mistaken, ur program gives wrong answer on this. > Const P : Array[0..7] of Byte= > (1,2,4,8,16,32,64,128); > > Type Arr = Array[0..125] of Byte; > > > Var N,M : Integer; > Map : Array[1..1000] of ^Arr; > Total : Integer; > > Procedure Init; > Var i,j : Integer; > R : Integer; > Begin > Readln(N,M); > For i := 1 to N do > Begin > New(Map[i]); > Fillchar(Map[i]^,Sizeof(Map[i]^),0); > For j := 1 to N do > Begin > Read(R); > R := 1-R; > Map[i]^[j Div 8] := Map[i]^[j Div 8] Or (P[j Mod 8]*R); > End; > End; > End; > > Procedure Print; > Var i : Integer; > Quit : Boolean; > Begin > Repeat > Quit := True; > For i := 1 to N do > If i<>M then > If Map[M]^[i Div 8] and P[i Mod 8]<>0 then > Begin > Dec(Map[M]^[i Div 8],P[i Mod 8]); > Writeln(M,' ',i); > M := i; > Quit := False; > Break; > End; > Until Quit; > End; > > Begin > Init; > Print; > End. |
|
|