|
|
вернуться в форумPlease give me some test Послано 法克 25 май 2004 11:53 {my wrong code} const maxn=600; type link=^re; re=record num:integer; q:link; end; var p:link; n:longint; va:array[1..maxn]of byte; g:array[1..maxn]of link; max:array[1..maxn,0..1]of longint; r:array[1..maxn]of boolean; procedure init; var x,y,i:longint; begin assign(input,'1039.in'); reset(Input); fillchar(r,sizeof(r),false); readln(n); for i:=1 to n do readln(va[i]); readln(y,x); while (x<>0) or (y<>0) do begin r[y]:=true; new(p); p^.num:=y; p^.q:=g[x]; g[x]:=p; readln(y,x); end; end; procedure solve(root:longint); var p:link; x,big:longint; begin new(p); p:=g[root]; while p<>nil do begin x:=p^.num; solve(x); inc(max[root,1],max[x,0]); if max[x,0]>max[x,1] then big:=max[x,0] else big:=max[x,1]; inc(max[root,0],big); p:=p^.q; end; inc(max[root,1],va[root]); end; procedure main; var i:longint; begin for i:=1 to n do if not(r[i]) then begin solve(i); if max[i,1]>max[i,0] then writeln(max[i,1]) else writeln(max[i,0]); exit; end; end; begin init; main; end. The code is wrong at the fourth test.I am pluzzled. Please give me some tests. Sorry for my fool. Two bugs 1). maxn must be 6000 2). va must be array of LongInt Re: Two bugs Послано 法克 26 май 2004 13:30 Thank you very much! I fix my code following your advice and AC now. I am so careless that I feel very ashamed.You are an alive Lei Feng(a great person).And I would like to make friends with you. Re: Two bugs 'An alive Lei Feng' is wrong, it must be 'a living Lei Feng'. |
|
|