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 |
为什么一直WA呢?var i, j, k, tot, ii: longint; n1, n2: longint; b: array[0..501] of boolean; a: array[0..501,0..501] of boolean; rec: array[0..501] of longint; ans: longint; x, y: longint; function dfs(x: longint): boolean; var i, j, k: longint; begin for i := 1 to n2 do if (not b[i]) and (a[x,i]) then begin b[i] := true; if (rec[i]=0) or (dfs(rec[i])) then begin rec[i] := x; exit(true); end; end; exit(false); end; begin assign(input,'d:\01.in'); reset(input); assign(output,'d:\01.out'); rewrite(output); readln(tot); for ii := 1 to tot do begin readln(n1,n2); fillchar(rec,sizeof(rec),0); fillchar(a,sizeof(a),false); for i := 1 to n1 do begin read(x); for j := 1 to x do begin read(y); a[x,y] := true; //a[y,x] := true; end; readln; end; ans := 0; for i := 1 to n1 do begin fillchar(b,sizeof(b),false); if dfs(i) then inc(ans); end; if ans=n1 then writeln('YES') else writeln('NO'); 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