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 |
FT.....USACO的数据都全对,但为什么WA?(程序内附)var map:array[1..50000,0..1000] of word; f:array[1..50000000,1..3] of word; i,j,k,n,t,a,b,cl,op:longint; procedure print; var i,l:integer; way:array[1..50000] of word; begin i:=op; writeln(f[op,3]); l:=0; while i<>0 do begin inc(l); way[l]:=f[i,1]; i:=f[i,2]; end; for i:=l downto 1 do writeln(way[i]); end; procedure search; var i:integer; begin for i:=1 to map[f[cl,1],0] do begin inc(op); f[op,1]:=map[f[cl,1],i]; f[op,2]:=cl; f[op,3]:=f[cl,3]+1; if map[f[cl,1],i]=k then begin print; halt; end; end; end; begin readln(n,k); for i:=1 to n do begin readln(a,b); inc(map[a,0]); map[a,map[a,0]]:=b; end; cl:=0; op:=1; f[1,1]:=1; f[1,2]:=0; f[1,3]:=1; repeat inc(cl); search; until cl>op; writeln(-1); end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator