|
|
back to board[Help] Crash #4 ( Access Violation ) - Do you know test 4 ? - Any helpful tests ? - If not, please pick bugs from my code. My algo: Find minimal, adjacent list, output sorted list. Tks a loooottttttt Program Prufer_Code; Type pnode = ^node; node = Record data:Longint; next:pnode; End; Var adjList:Array[0..7500] of pnode; temp:pnode; A,C,minS:Array[0..7500] of Longint; n,i,j,s,p,q,m:Longint; fi:Text; Procedure add(k:Longint;var x:pnode); Var y,z:pnode; Begin If (x=nil) then Begin new(x); x^.data:=k; End Else Begin new(y); y^.data:=k; y^.next:=x; x:=y; End; End; Begin n:=0; While not seekeof do Begin inc(n); Read(A[n]); End; For i:=1 to n+1 do Begin inc(C[i]); inc(C[A[i]]); End; dec(C[A[n+1]],2); p:=0; For i:=1 to n+1 do If C[i]=1 then Begin inc(p); minS[p]:=i; End; For i:=1 to n do Begin q:=minS[1]; m:=1; For j:=2 to p do If minS[j]<q then Begin q:=minS[j]; m:=j; End; j:=q; minS[m]:=99999; add(j,adjList[A[i]]); add(A[i],adjList[j]); dec(C[A[i]]); If C[A[i]]=1 then Begin inc(p); minS[p]:=A[i]; End; End; For i:=1 to n+1 do Begin FillChar(C,sizeof(C),0); temp:=adjList[i]; p:=0; while temp<>nil do Begin inc(C[temp^.data]); temp:=temp^.next; End; Write(i,': '); For j:=1 to 7500 do If C[j]=1 then Write(j,' '); Writeln; End; End. Re: [Help] Crash #4 ( Access Violation ) I receive Access violation it test 4 too. :( Do anyone know the test? test 4 Posted by BaJIuK 4 Nov 2011 22:30 I was crashed on this test, because i forget to fill inf in cells of heap, before i start to solve. Also you can try this test: input: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 output: is obvious Re: [Help] Crash #4 ( Access Violation ) Are you store the double edge but didn't double the edge memory? |
|
|