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 |
福利var a:array[1..10000] of longint; i,j,n,t,x,y,k:longint; b:array[1..10000] of boolean; begin readln(t); for i:=1 to 10000000 do inc(t); for i:=1 to 10000000 do dec(t); for i:=1 to t do begin fillchar(a,sizeof(a),0); readln(n); for j:=1 to n-1 do begin readln(x,y); a[y]:=x; end; readln(x,y); fillchar(b,sizeof(b),false); b[x]:=true; repeat k:=x; b[k]:=true; x:=a[k]; until x=0; repeat k:=y; if b[k] then begin writeln(k); break; end else b[k]:=true; y:=a[k]; until y=0; end; end. Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator