Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
请帮忙看看偶这个pas的程序有啥bug?为什么会wa掉?program p1330; var f:array[0..11000]of integer; b:array[0..11000]of boolean; t,i,n,x,y:integer; procedure init; var i,a,b:integer; begin readln(n); fillchar(f,sizeof(f),0); fillchar(b,sizeof(b),false); for i:=1 to n-1 do begin readln(a,b); f[b]:=a; end; readln(x,y); end; procedure work; var c:integer; begin c:=x;b[c]:=true; while c<>0 do begin b[c]:=true; c:=f[c]; end; c:=y; while not b[c] do c:=f[c]; writeln(c); end; begin // assign(input,'input.txt');reset(input); // assign(output,'output.txt');rewrite(output); readln(t); for i:=1 to t do begin init; work; end; // close(input);close(output); end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator