Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么一直WA呢?

Posted by hell_angel at 2011-05-11 16:46:17 on Problem 1469
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator